2017 © Pedro Peláez
 

library raw-router

RawRouter is a simple router used by RawPHP framework and other applications.

image

rawphp/raw-router

RawRouter is a simple router used by RawPHP framework and other applications.

  • Monday, December 22, 2014
  • by rawphp
  • Repository
  • 1 Watchers
  • 0 Stars
  • 323 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

RawRouter - A Simple Routing Service for MVC PHP Applications

Build Status Coverage Status Latest Stable Version Total Downloads Latest Unstable Version License, (*1)

SensioLabsInsight, (*2)

Package Features

  • Simple to use router
  • MVC style routing

Installation

Composer

RawRouter is available via Composer/Packagist., (*3)

Add "rawphp/raw-router": "0.*@dev" to the require block in your composer.json and then run composer install., (*4)

{
        "require": {
            "rawphp/raw-router": "0.*@dev"
        }
}

You can also simply run the following from the command line:, (*5)

composer require rawphp/raw-router "0.*@dev"

Tarball

Alternatively, just copy the contents of the RawRouter folder into somewhere that's in your PHP include_path setting. If you don't speak git or just want a tarball, click the 'zip' button at the top of the page in GitHub., (*6)

Basic Usage

<?php

use RawPHP\RawRouter\Router;

// configuration
$config = array(
    'default_controller' => 'home',                             // the controller that will handle requests if the requested controller is not found
    'default_action'     => 'index',                            // the default action (method) to call if the requested action is not found
    'namemspace'         => 'RawPHP\\RawRouter\\Controllers\\', // the controllers namespace, leave empty if namespaces are not used
);

// get new router instance
$router = new Router( );

// initialise router
$router->init( $config );

// example request
// http://example.com/users/get/1

$route = 'users/get';                                           // the route must be in one of the following formats [ controller, controller/action, controller/action/param/param/... ]
$params = array( 1 );                                           // array of values to be passed to the action method in the correct order

// create controller
$controller = $router->createController( $route, $params );

// run controller action
$controller->run( );

License

This package is licensed under the MIT. Read LICENSE for information on the software availability and distribution., (*7)

Contributing

Please submit bug reports, suggestions and pull requests to the GitHub issue tracker., (*8)

Changelog

22-09-2014

  • Tested on PHP 5.3

20-09-2014

  • Replaced php array configuration with yaml

18-09-2014

  • Added loadView() method to Controller which can load html templates
  • Added LEController that extends Controller and provides languages features. It can load different language translations required for use in html templates.
  • Updated to work with the latest rawphp/rawbase package.
  • Added init() methods to both Controllers to ensure that the controller gets initialised properly.

17-09-2014

  • Updated to work with the latest rawphp/rawbase package.
  • Added extra hooks to Action.
  • Removed the constructor added new setAction( IAction ) method on Controller.

14-09-2014

  • Implemented the hook system.
  • Renamed RawController -> Controller.

12-09-2014

  • Changed router constructor to take a configuration array rather than individual parameters.

11-09-2014

  • Initial Code Commit

The Versions

22/12 2014

dev-master

9999999-dev http://rawphp.org

RawRouter is a simple router used by RawPHP framework and other applications.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Tom Kaczocha

routing