Peninsula - Backend
The backend is in charge of the functional APIs which allow the frontend, bridge and client to work properly.
Design Considerations
- Write sane and safe code: Enable as much strictness as possible without cutting into developer sanity.
- Keep it stupid & simple: We don't need a lot of complexity where we're going, the simple stuff works just fine.
- Widely supported: Don't rely on functionality, features, or languages that aren't available widely. PHP fits this perfectly, it's already everywhere.
Installation
- Copy the content of this directory to your web server.
- Point the webroot into the
public/directory. - Ensure that all requests either resolve to an existing file or are internally redirected to
index.php. - Done.
Requirements
- A functional Web server with internal redirects.
- PHP 8.1 or newer
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;
}
}