Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/alin11/routerion
PHP fast and powerful router
https://github.com/alin11/routerion
php rest-api router
Last synced: 3 months ago
JSON representation
PHP fast and powerful router
- Host: GitHub
- URL: https://github.com/alin11/routerion
- Owner: AliN11
- License: mit
- Created: 2018-03-28T08:27:56.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2019-02-25T07:49:44.000Z (almost 6 years ago)
- Last Synced: 2024-04-24T13:10:28.508Z (9 months ago)
- Topics: php, rest-api, router
- Language: PHP
- Size: 13.7 KB
- Stars: 10
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Routerion - PHP Router
A simple, fast and powerful PHP router
* Define routes easily
* Dynamic route parameters
* Supports various HTTP methods
* REST API Support## Installation
1. You can install Routerion with composer:
```$ composer require alin11/routerion```
2. Create a `.htaccess` file on the root directory:
```htaccess
Options +FollowSymLinks
RewriteEngine OnRewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]RewriteRule ^(.*)$ index.php [NC,L]
```3. Create `config.php` file or add following `PHP Constants` to your configuration file:
```php
get('/', 'HomeController@index');
$route->get('/users', 'Auth\UsersController@index');
$route->get('/users/{name}/{age?}', 'Auth\UsersController@single');$route->post('/get-user-info/{id}', 'Auth\UsersController@getUserInfo');
$route->get('closure', function(){
echo 'This is closure';
});$route->get('closure-with-parameters/{required}/{optional?}', function($required, $optional = null){
echo $required;
echo $optional;
});$route->run();
```### Controllers
Controller files are located in `Controllers` directory. Edit `config.php` constants if you have different controllers directory or namespace.
## License
MIT Licensed: