From e873ec0557edaae7ada58b09803b5ad7e8d9f7b9 Mon Sep 17 00:00:00 2001 From: Max Date: Wed, 24 Jul 2019 17:56:58 +0200 Subject: [PATCH] Update README.md --- README.md | 47 ++++++++++++++--------------------------------- 1 file changed, 14 insertions(+), 33 deletions(-) diff --git a/README.md b/README.md index 2aec65a..5c7ef8e 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,9 @@ # Simple PHP Router -Hey! This is a simple and small php router that can handel the whole url routing for your project. -It utilizes RegExp and PHPs anonymous functions to create a lightweight and fast routing system. -The router supports dynamic path parameters, special 404 and 405 routes as well as verification of request methods like get, post, put, delete etc... -The codebase is very small and very easy to understand. So you can use it as boilerplate for a more complex router. +Hey! This is a simple and small PHP router that can handle the whole URL routing for your project. +It utilizes RegExp and PHP's anonymous functions to create a lightweight and fast routing system. +The router supports dynamic path parameters, special 404 and 405 routes as well as verification of request methods like GET, POST, PUT, DELETE, etc. +The codebase is very small and very easy to understand. So you can use it as a boilerplate for a more complex router. Take a look at the index.php file. As you can see the ```Route::add()``` method is used to add new routes to your project. The first argument takes the path segment. You can also use RegExp in there to parse out variables. @@ -12,11 +12,11 @@ The third argument will match the request method. The default method is 'get'. ## Simple example: ``` -include('Route.php'); +include 'Route.php'; -Route::add('/user/([0-9]*)/edit',function($id){ - echo 'Edit user with id '.$id.'
'; -},'get'); +Route::add('/user/([0-9]*)/edit',function($id) { + echo 'Edit user with id '.$id.'
'; +}, 'get'); Route::run('/'); ``` @@ -24,7 +24,7 @@ Route::run('/'); You will find a more complex example with a build in navigation in the index.php file. ## Use a different basepath -If your script lives in a subfolder e.g. /api/v1 set this basepath in your run method: +If your script lives in a subfolder (e.g. /api/v1) set this basepath in your run method: ```Route::run('/api/v1');``` @@ -51,34 +51,15 @@ I have created a little Docker test setup. 3. Open your browser and navigate to http://localhost ## Test setup with Vagrant (not longer maintained) -There is a little Vagrant test setup. Just run ```vagrant up``` to spin up a Apache2 Webserver on Ubuntu. Then navigate to http://router.local after adding the machine IP to your hosts file. This test setup is not longer maintained and will probably break in future. Use the docker test setup instead. +There is a little Vagrant test setup. Just run ```vagrant up``` to spin up an Apache2 web server on Ubuntu. Then navigate to http://router.local after adding the machine IP to your hosts file. This test setup is not longer maintained and will probably break in the future. Use the Docker test setup instead. ## Themes, layouts, pages and components If you are interested in some basic concepts on how to build a simple PHP page using this router including themes, layouts, pages and components checkout this repo: https://github.com/steampixel/simplePHPPages -This project will give you some ideas and basics on how to get started with no dependencys. +This project will give you some ideas and basics on how to get started with no dependencies. ## Todo * Create demo configuration for nginx -* Create composer configuration and upload to packagist.org +* Create Composer configuration and upload to packagist.org -## MIT License - -Copyright (c) 2018 SteamPixel - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. +## License +This project is licensed under the MIT License. See LICENSE for further information.