Skip to content

rakaaditya/panada-router

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PanadaRouter

Build Status

A simple library to route Panada Framework 1.*

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

$route->run();

Installation

The recommended way to install PanadaRouter is through Composer.

# Install Composer
curl -sS https://getcomposer.org/installer | php

Next, run the Composer command to install the latest version of PanadaRouter:

composer.phar require rakaaditya/panada-router

Configuration

First, add the following configuration at app/config/main.php file:

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

Then, create AliasController.php in Controllers folder:

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();
    }
}

Basic Usage

// 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');

Grouping with prefix

$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');
});

About

A simple library to route Panada Framework 1.*

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages