Simple REST API Server written in PHP, accepting CORS Requests and designed with MVC Pattern.
To run this project you need the LAMP server to be installed on your machine (See this guide).
You need also to enable the use of htaccess files, in order to make it possible follow these simple steps:
-
First enable the module rewrite using this command:
sudo a2enmod rewrite -
Go into the sites-available folder:
cd /etc/apache2/sites-available -
Edit the Apache configuration (e.g.
default.conf) by setting AllowOverride to All.
BEFORE<Directory /var/www/html/> # ... AllowOverride None # ... </Directory>AFTER
<Directory /var/www/html/> # ... AllowOverride All # ... </Directory> -
Restart Apache:
sudo service apache2 restart
You can avoid using htaccess by configuring directly the Apache configuration.
- Go into the sites-available folder:
cd /etc/apache2/sites-available - Edit the Apache configuration (e.g.
default.conf) AFTER<Directory "/var/www/html/"> # ... AllowOverride None <IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^api/v1/foo/* /routes/foo.php [QSA,L] RewriteRule ^api/v1/bar/* /routes/bar.php [QSA,L] </IfModule> </Directory> - Restart Apache:
sudo service apache2 restart
Mattia Corvaglia - corvagliamattia@gmail.com - mattiacorvaglia.com