https://github.com/mattiacorvaglia/php-rest-api
REST API Server written in PHP
https://github.com/mattiacorvaglia/php-rest-api
api php rest server
Last synced: about 1 month ago
JSON representation
REST API Server written in PHP
- Host: GitHub
- URL: https://github.com/mattiacorvaglia/php-rest-api
- Owner: mattiacorvaglia
- License: mit
- Created: 2016-12-31T14:44:06.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2021-05-12T12:00:28.000Z (about 5 years ago)
- Last Synced: 2025-03-21T12:30:37.697Z (over 1 year ago)
- Topics: api, php, rest, server
- Language: PHP
- Homepage:
- Size: 19.5 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# RESTful API implementation in PHP
Simple REST API Server written in PHP, accepting CORS Requests and designed with MVC Pattern.
## Getting Started
### Prerequisites
To run this project you need the **LAMP** server to be installed on your machine (See this [guide](http://www.mattiacorvaglia.com/install_lamp.html)).
You need also to enable the use of **htaccess** files, in order to make it possible follow these simple steps:
1. First enable the module **rewrite** using this command: `sudo a2enmod rewrite`
2. Go into the **sites-available** folder: `cd /etc/apache2/sites-available`
3. Edit the Apache configuration (e.g. `default.conf`) by setting **AllowOverride** to **All**.
BEFORE
```
# ...
AllowOverride None
# ...
```
AFTER
```
# ...
AllowOverride All
# ...
```
4. Restart Apache: `sudo service apache2 restart`
### Alternatives
You can avoid using htaccess by configuring directly the Apache configuration.
1. Go into the **sites-available** folder: `cd /etc/apache2/sites-available`
2. Edit the Apache configuration (e.g. `default.conf`)
AFTER
```
# ...
AllowOverride None
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]
```
3. Restart Apache: `sudo service apache2 restart`
## Authors
**Mattia Corvaglia** - [corvagliamattia@gmail.com](mailto:corvagliamattia@gmail.com) - [mattiacorvaglia.com](http://mattiacorvaglia.com)