Skip to content

elvislakota/route

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Route

Author

This package is compliant with PSR-7. If you notice compliance oversights, please send a patch via pull request.

Install

Via Composer

$ composer require elvislakota/router:dev-master

Requirements

The following versions of PHP are supported by this version.

  • PHP 7.1
  • PHP 7.2

Usage

Here's a basic usage example:

.htaccess

Create a .htaccess file in your htdocs folder

<ifModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_URI} !index
    RewriteRule (.*) public/ [L]

</ifModule>


Then create a new Folder 'public' in your htdocs folder and add index.php with content

<?php

require '../vendor/autoload.php';

//Your middleware class
$middlewareTest = new \elvislakota\Router\example\MiddlewareTest();

//Custom error messages for the error 404,405 and middleware
$exceptionTest = new \elvislakota\Router\example\ExceptionTest();

//Router
$router = new \elvislakota\Router\Router($exceptionTest);

//Add a route
$router->addRoute(\elvislakota\Router\Router\Route::getRoute('GET','/',
    'elvislakota\Router\example\ControllerTest::helloWorld', $middlewareTest));

//Dispatch and emit data
$serverResponse = $router->dispatch();
$router->emit();

Testing

$ vendor/bin/phpunit

Contributing

Contributions are welcome and will be fully credited.

We accept contributions via Pull Requests on Github.

Credits

License

The MIT License (MIT). Please see License File for more information.

About

Fast PHP router build with nikic/FastRoute

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages