Files
Peninsula/backend
2026-02-02 20:56:18 +01:00
..
2026-02-02 20:56:18 +01:00

Peninsula - Backend

The backend provides all necessary API endpoints to guarantee that the frontend does not require any server-side dynamic content generation. This should ensure that hosting the frontend is much cheaper than hosting the backend, likely requiring far less servers to handle. This backend is based on the lightweight CodeIgniter framework to simplify how much work is required for the implementation.

Requirements

We require some PHP modules for proper operation:

  • json (enabled by default - don't turn it off)
  • intl
  • mbstring

And depending on your Database of choice, one of:

Installation

Released Build

  1. Download the backend package from the provided release packages.
  2. Extract it on your server.
  3. Perform the Configuration step.
  4. Set the web root to be the public/ directory.
  5. Set up rewrites or try_files to rewrite any non-existing request to /index.php.
  6. Enjoy.

Local Build

  1. Make a fresh clone of this repository, or run git clean -fqX.
  2. Run composer install --no-dev.
  3. Copy the contents of this directory to the machine that is supposed to host the backend.
  4. Set up your webserver to have a virtual host with a root directory pointing at public/.
  5. Ensure that all requests that don't match an exact file are forwarded to index.php.
  6. Enjoy.

Example Server Configurations

These examples are provided without warranty or guarantee of functionality. They're references to look at and configure your own server with.

nginx

server {
	# The hostname under which we can find this server.
	server_name "backend.peninsula.example.com";

	# Listen for both HTTP and HTTPS.
	listen 80;
	listen [::]:80;
	listen 443 ssl;
	listen [::]:443 ssl;

	# Enable HTTP2 and QUIC (HTTP3).
	http2 on;
	quic_gso on;
	
	# Set up the necessary SSL certificates for HTTPS.
	ssl_certificate "/etc/certs/snakeoil.pub";
	ssl_certificate "/etc/certs/snakeoil.priv";

	# Set the root to the proper directory.
	root "/var/www/peninsula/backend/public/";

	# Try a few paths before handing it off to the framework.
	try_files $uri $uri/ /index.php?$request_uri;

	# Disallow access to all files starting with a '.', except for localhost.
	location ~ /\. {
		allow 127.0.0.1;
		deny all;
	}

	# Turn off logging for common files.
	location = /favicon.ico {
		access_log off;
		log_not_found off;
		error_log off;
	}
	location = /robots.txt {
		access_log off;
		log_not_found off;
		error_log off;
	}

	# Handle PHP Files
	location ~* [^/]\.php(|/.*)(|\?.*)$ {
		include                         "fastcgi.conf";
		fastcgi_index                   index.php;
		fastcgi_split_path_info         ^(.+\.php)(|/.*)$;
		fastcgi_param PATH_INFO         $fastcgi_path_info;

		# Always try the PHP files
        try_files                       $fastcgi_script_name?$request_uri $fastcgi_script_name =404;
	}
}