Download the PHP package scrawler/router without Composer
On this page you can find all versions of the php package scrawler/router. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package router
Scrawler Router
๐ฅAn Fully Automatic, Framework independent, RESTful PHP Router component๐ฅ
๐ฎ๐ณ Made in India ๐ฎ๐ณ
Complete docs can be found here
๐ค Why use Scrawler Router?
- Fully automatic, you dont need to define single manual route.
- Support manual route defination for your edge use case.
- No configrations , works out of the box with any php project.
- Stable and well tested.
- Saves lot of time while building RESTful applications
๐ป Installation
You can install Scrawler Router via Composer. If you don't have composer installed , you can download composer from here
โจ Setup
Note 4.x release changes the way router handles request and response, if you still wanna continue using old way with symfony components goto 3.x branch
Done now whatever request occurs it will be automatically routed . You don't have define a single route
โ๏ธ Manual routing
Information on manual routing can be found in docs
๐ฆ How it Works?
The automatic routing is possible by following some conventions. Lets take a example lets say a controller Hello
now calling localhost/hello/world
from your browser you will see hello world
on your screen.
๐ฅ How does it do it automatically?
Each request to the server is interpreted by Scrawler Router in following way:
METHOD /controller/function/arguments1/arguments2
The controller and function that would be invoked will be
For Example the following call:
GET /user/find/1
would invoke following controller and method
In above example 1
will be passed as argument $id
โ๏ธ How should I name my function for automatic routing?
The function name in the controller should be named according to following convention:
methodFunctionname
Note:The method should always be written in small and the first word of function name should always start with capital.
Method is the method used while calling url. Valid methods are:
Some eg. of valid function names are:
Invalid function names are:
๐ Website home page
Scrawler Router uses a special function name allIndex()
and special controller name Main
. So If you want to make a controller for your landing page \
the controller will be defines as follows
๐ Main Controller
Class name with Main
signifies special meaning in Scrawler Router , if you wanna define pages route URL you can use main controler
๐ Index function
Just like Main
controller allIndex(), getIndex(), postIndex()
etc signifies a special meaning , urls with only controller name and no function name will try to resolve into this function.
๐ Supporters
If you have reached here consider giving a star to help this project โค๏ธ
Thank You for your forks and contributions
๐ฅ๏ธ Server Configuration
Apache
You may need to add the following snippet in your Apache HTTP server virtual host configuration or .htaccess file.
Alternatively, if youโre lucky enough to be using a version of Apache greater than 2.2.15, then you can instead just use this one, single line:
IIS
For IIS you will need to install URL Rewrite for IIS and then add the following rule to your web.config
:
Nginx
Under the server
block of your virtual host configuration, you only need to add three lines.
๐ License
Scrawler Router is created by Pranjal Pandey and released under the MIT License.