PHP code example of rakaaditya / panada-router

1. Go to this page and download the library: Download rakaaditya/panada-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/ */

    

rakaaditya / panada-router example snippets


$route->get('/home', 'HomeController@index');
$route->get('{username}/{id}/{slug}', 'ArticleController@detail');
$route->post('post/create', 'ArticleController@store');

$route->run();

'alias' => [
    'controller' => [
        'class' => 'AliasController',
        'method' => 'index'
    ],
 ],

namespace Controllers;
use Rakaaditya\PanadaRouter\Routes as Route;

class AliasController
{
    public function index()
    {
        $route = new Route;
        $route->get('coba', 'HomeController@index');
        $route->get('{username}/{id}/{slug}', 'ArticleController@detail');

        // Let's run through the route!!
        $route->run();
    }
}


// GET
$route->get('posts', 'PostController@posts');
// POST
$route->post('posts/create', 'PostController@create');
// PUT
$route->put('posts/{id}/update', 'PostController@update');
// DELETE
$route->delete('posts/{id}/delete', 'PostController@delete');

$route->group('posts', function($route) {
    $route->get('/', 'PostController@posts');
    $route->post('create', 'PostController@create');
    $route->put('{id}/update', 'PostController@update');
    $route->delete('{id}/delete', 'PostController@delete');
});
bash
# Install Composer
curl -sS https://getcomposer.org/installer | php