Installing
Requirements
- PHP ≥ 8.4.0
To work around PHP's inconsistencies with where it reads request data from (sometimes superglobals, sometimes php://input
), Aphiria requires the following setting in either a .user.ini or your php.ini:
enable_post_data_reading = 0
This will disable automatically parsing POST data into $_POST
and uploaded files into $_FILES
.
Note: If you're developing any non-Aphiria applications on your web server, use .user.ini to limit this setting to only your Aphiria application. Alternatively, you can add
php_value enable_post_data_reading 0
to an .htaccess file or to your httpd.conf.
Installing
Aphiria comes with a skeleton app to help you quickly get up and running. It can be installed using Composer:
composer create-project aphiria/app --prefer-dist --stability dev
Be sure to configure your server to finish the installation.
Note: You can download Composer from here.
Libraries
Aphiria is broken into various libraries, each of which can be installed individually:
aphiria/api
aphiria/application
aphiria/authentication
aphiria/authorization
aphiria/collections
aphiria/console
aphiria/content-negotiation
aphiria/dependency-injection
aphiria/exceptions
aphiria/framework
aphiria/io
aphiria/middleware
aphiria/net
aphiria/psr-adapters
aphiria/reflection
aphiria/router
aphiria/security
aphiria/sessions
aphiria/validation
Server Config
Regardless of the approach you take below, you can access your Aphiria app via http://localhost:8080. Just make sure the tmp directory is writable from PHP.
Docker Compose
The skeleton app provides support for Docker Compose to simplify getting up and running with an nginx web server and Xdebug. This setup is only meant for local development and is not meant for production. To get up and running, simply run:
docker compose up -d --build app
To start debugging with Xdebug, configure your IDE to map your checked out Aphiria code to the /app directory within the php service created by Docker Compose. Ensure that your IDE is configured to listen to port 9004 for Xdebug connections.
Built-in PHP Web Server Config
To run Aphiria locally via the built-in PHP web server, run the following:
php aphiria app:serve
Apache Config
Create a virtual host in your Apache config with the following settings:
<VirtualHost *:80>
ServerName YOUR_SITE_DOMAIN
DocumentRoot YOUR_SITE_DIRECTORY/public
<Directory YOUR_DOCUMENT_ROOT/public>
<IfModule mod_rewrite.c>
RewriteEngine On
# Handle trailing slashes
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Create pretty URLs
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
</Directory>
</VirtualHost>
nginx Config
Add the following to your nginx config:
server {
listen 80;
server_name YOUR_SITE_DOMAIN;
root YOUR_SITE_DIRECTORY/public;
index index.php;
# Handle trailing slashes
rewrite ^/(.*)/$ /$1 permanent;
# Create pretty URLs
location / {
try_files $uri $uri/ /index.php$is_args$args;
}
location ~ \.php$ {
include /etc/nginx/fastcgi_params;
fastcgi_index index.php;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass unix:/run/php/php8.2-fpm.sock;
}
}
Caddy Config
Add the following to your Caddyfile config:
YOUR_SITE_DOMAIN:80 {
rewrite {
r .*
ext /
to /index.php?{query}
}
fastcgi / 127.0.0.1:9000 php {
ext .php
index index.php
}
}
Versioning
Aphiria follows semantic versioning 2.0.0. For more information on semantic versioning, check out its documentation.