Download the PHP package mehrdad-dadkhah/laravel-vroute without Composer
On this page you can find all versions of the php package mehrdad-dadkhah/laravel-vroute. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download mehrdad-dadkhah/laravel-vroute
More information about mehrdad-dadkhah/laravel-vroute
Files in mehrdad-dadkhah/laravel-vroute
Package laravel-vroute
Short Description PHP library for laravel to add automated/conventional routes with versioning
License AGPL-3.0-only
Homepage https://github.com/Mehrdad-Dadkhah/laravel-vroute
Informations about the package laravel-vroute
Laravel-VRoute
PHP library for laravel to add automated/conventional routes with versioning.
This package help developers and teams to have versioning URI base on project structure, and no need to write new line of code for new route.
This package is configable for example you can change template of controller names and ....
If you have method in version 1 of and you call so router call index method of version 1 immidately, but if call what happen?
you have 3 choice:
-
move all codes from version 1 to version 2!
-
add new route for that point to version 1!
- in your application you use different version of api base on active version of it! you have know multiple active api version, you should support all, you should remember or check every day! where which version is in use and .....
So to fix this problem/need I develop this package. VRoute for check version 2 of PostController and if it has not this method automatically switch to one version.
Maybe you ask this process is heavy and may make performance problem, yes but I add good caching system to it and we process only one time.
Benefit case and samples
-
Simplification and less code
Before using VRoute you may have something like this:
And after use VRoute it would be:
- Procedural unity
- Team conventions
-
More redable code in controller
Before use Vroute:
After use VRoute:
System requirements
Tested with >=7.1, following binaries need to be installed
Installation
Usage
Put this code in your route file (for example routes/api.php)
That's it!
If you have sub-directory in you project, for example admin/client and .... should make them available for VRoute:
How to set a middleware?
You can set middleware in 8 layers or ways!
-
Set for controller in all version and directory
-
Set for controller in specific directory (for example only for in sub-dir)
-
Set for controller in specific version (for example only for in )
-
Set for controller in specific directory and version (for example only for in sub-dir and only version 1)
-
Set for controller and specific action(method) (for example only for and action)
-
Set for controller and specific action(method) in specific version (for example only for and action in )
-
Set for controller and specific action(method) in specific directory (for example only for and action in sub-dir)
- Set for controller and specific action(method) in specific directory and version (for example only for and action in and )
What about you set all 8 kind of middleware for one controller?
From top to bottom, if match the route, all middlewares will be merged.
For example we set:
-
middleware for (without specify directory and version)
-
middleware for for directory (without specify version)
-
middleware for for version (without specify directory)
- middleware for for directory and version
Now we call , so all of the middlewares (,,,) will be fire
But If call , only and {HTTPMETHOD}{ActionName}GETProfile```. this convention add to force action about it's method, force methods to response to only one type of http call method and make controller more readable.
To Do
- Cache found routes
- Add clean cache command
- Add VRoute:cache command to iterate on controllers and cache all routes
- Response cache feature
License
laravel-vroute is licensed under the GPLv3 License.