Routing
Table of contents
Puko framework have different kind of routing clause “as-is” controller functionality, we call it sorted from most ussage in order: view
, service
, and console
. Puko framework can scaffolds Routing process with pukoconsole
tools included as dev-dependency to speed up your web app develpment process.
Create New Routing
To add new Routing, you can type in console/terminal/powershell:
php puko routes <controller_clause> add <rest_style_urls>
rest_style_urls can typed with {?}
or ?
in PowerShell to identify it as dynamic PHP GET parameters.
For example:
php puko routes view add member/?/reports
Items asked for the rest of process:
Items | Description | Examples |
---|---|---|
Controller name | File name. You can use \ to place the file in sub-directories | member\reports |
Function name | Function name | pages |
Accept? | HTTP verb GET,POST,PUT,PATCH,DELETE multiple by commas | get,post |
Importand: While rotes using / slash, You must using \ backslash for separating controller to prevent directory path error on diferent type of Operating Systems.
File generated after New Routing
After completed, puko is updating and auto-generated these files:
config/routes.php
controller/member/reports.php
If the routes clause was view
puko will also update and auto-generated these files:
assets/html/en/member/reports/pages.html
assets/html/id/member/reports/pages.html
You can also see all registered routes with this command:
php puko routes list
All generated routes stored in config/routes.php
. So it’s important to not manually edit those file to maintain Routing structure.
Update Routing
If you want to update or modify the HTTP verb accepted from the Routing url registered, you can update it with command:
php puko routes view update member/?/reports
Apply your revision when answering items asked.
Delete Routing
Puko also can remove unused routes with remove command:
php puko routes view remove member/{?}/reports
For security concerns puko not deleting the .php
and .html
file. You must review and remove it manually.