Download the PHP package karewan/knroute without Composer
On this page you can find all versions of the php package karewan/knroute. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download karewan/knroute
More information about karewan/knroute
Files in karewan/knroute
Package knroute
Short Description Simple and fast PHP 8.3+ router with routes attributes and caching (+Inertia.js compatiblity)
License MIT
Homepage https://github.com/Karewan/KnRoute
Informations about the package knroute
KnRoute
Simple and fast PHP 8.3+ router with routes attributes and caching (+Inertia.js compatiblity).
Table of content
- KnRoute
- Table of content
- Installation
- Requirements
- Getting started
- Usage
- Register routes from the controllers and run the router
- Different types of routes
- Add route attributes to controller methods
- Use variables inside a path
- Variable types with their corresponding regex
- Create a middleware
- Use a middleware on a class
- Use a middleware on a class method
- Create a middleware with parameters
- Use a middleware with parameters
- HttpUtils class (all methods are static)
- Inertia.js plugin usage
- Init the plugin
- The template file
- Render a component with its props
- Share props
- View data
- Inertia class (all methods are static)
- Changelog
- License
Installation
Requirements
PHP 8.3+
Getting started
Usage
Register routes from the controllers and run the router
Different types of routes
All are method attributes.
Add route attributes to controller methods
Use variables inside a path
Name of the variable followed by the type.
Variable types with their corresponding regex
Create a middleware
Use a middleware on a class
Will be executed before instantiating the class.
Use a middleware on a class method
Will be executed after instantiating the class and before calling the method.
Create a middleware with parameters
Use a middleware with parameters
HttpUtils class (all methods are static)
Karewan\KnRoute\HttpUtils::
Global constant (bool)
Inertia.js plugin usage
Init the plugin
Must be init before the router.
If you don't have a view rendering method, you can use the method below.
The template file
App/Views/MyTemplate.php
Render a component with its props
Share props
Shared props will be merged with Inertia::render props. Must be called before the Inertia::render method.
View data
Data to send to the template file. Must be called before the Inertia::render method.
Usage from the template file
Inertia class (all methods are static)
Karewan\KnRoute\Plugins\Inertia\Inertia::
Global constant (bool, only defined if Inertia::init is called)
Changelog
See the changelog here
License
See the license here