From cdeb25f770c6e30d339d5b99a9ff6d93c27829b3 Mon Sep 17 00:00:00 2001 From: SteamPixel Date: Tue, 14 Jan 2020 13:00:23 +0100 Subject: [PATCH] Added composer instruction --- README.md | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index fb59832..e996940 100644 --- a/README.md +++ b/README.md @@ -12,18 +12,42 @@ The third argument will match the request method. The default method is 'get'. ## Simple example: ```php -use Steampixel\Route; +// Require the class include 'src\Steampixel\Route.php'; +// Use this namespace +use Steampixel\Route; + +// Add the first route Route::add('/user/([0-9]*)/edit', function($id) { echo 'Edit user with id '.$id.'
'; }, 'get'); +// Run the router Route::run('/'); ``` You will find a more complex example with a build in navigation in the index.php file. +## Installation using Composer +Just run `composer require steampixel/simple-php-router` +Than add the autoloader to your project like this: +```php +// Autoload files using composer +require_once __DIR__ . '/vendor/autoload.php'; + +// Use this namespace +use Steampixel\Route; + +// Add your first route +Route::add('/', function() { + echo 'Welcome :-)'; +}); + +// Run the router +Route::run('/'); +``` + ## Use a different basepath If your script lives in a subfolder (e.g. /api/v1) set this basepath in your run method: