Could #-attributes in PHP 8.1 be used for routes in the future? - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28) +--- Forum: CodeIgniter 4 Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=31) +--- Thread: Could #-attributes in PHP 8.1 be used for routes in the future? (/showthread.php?tid=83108) |
Could #-attributes in PHP 8.1 be used for routes in the future? - tgix - 09-21-2022 I have no clue what I am talking about so I am just dumping my thoughts here... I have a fairly large project in CI4.2 which is a REST backend to an admin interface written as SPA JavaScript application. The Routes.php file is starting to get very long with segments like this to manage a single object in the system: PHP Code: // Routes for handling Users and Employees Especially the filter settings are hord to remember the correct syntax. Also making sure that all possible routes are covered and maintained is getting harder and harder. Refactoring is also a nightmare. So I thought: what if Attributes in the Controller itself could be used to describe the routes allowed in the Controller. Sort of lite auto-routes from before but with better maintainability. Example: PHP Code: <?php As you can see I don't have a clue if this is possible or not but I just wanted to put my thoughts in writing and possibly start a discussion. /Mattias RE: Could #-attributes in PHP 8.1 be used for routes in the future? - vyatka - 09-21-2022 maybe https://github.com/kenjis/ci4-attribute-routes helps RE: Could #-attributes in PHP 8.1 be used for routes in the future? - iRedds - 09-21-2022 https://forum.codeigniter.com/showthread.php?tid=81038 CodeIgniter4 Attribute Routes RE: Could #-attributes in PHP 8.1 be used for routes in the future? - tgix - 09-21-2022 (09-21-2022, 08:22 AM)iRedds Wrote: https://forum.codeigniter.com/showthread.php?tid=81038 CodeIgniter4 Attribute Routes Cool, thanks. RE: Could #-attributes in PHP 8.1 be used for routes in the future? - titounnes - 09-25-2022 Attribute route only runs in php version 8, while ci4 allows php version 7. RE: Could #-attributes in PHP 8.1 be used for routes in the future? - tgix - 09-25-2022 (09-25-2022, 07:22 AM)titounnes Wrote: Attribute route only runs in php version 8, while ci4 allows php version 7. Correct, but with 7.4 becoming unsupported in 2 months I wouldn't be surprised if support for PHP 7 will be dropped soon. |