PHP code example of grephq / php-router

1. Go to this page and download the library: Download grephq/php-router library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

grephq / php-router example snippets


$route->get('/users', function() {
    Index::get();
});

$route->post('/user/<string:name>', function() {
    Index::post();
});

$route->delete('/user/<int:id>', function() {
    Index::delete();
});

class User extends BaseController
{
    public static function get()
    {
        render('index.php', array('title' => 'Index Page'));
    }

    public static function post()
    {
        json(reqVar('name'), 200);
    }

    public static function delete()
    {
        xml('Delete Request', 200);
    }
}
app.php
bash
git clone https://github.com/Tomiwa-Ot/php-router.git
cd php-router
composer install
bash
composer create-project grephq/php-router
cd php-router
composer install