CodeIgniter Forums
CodeIgniter4 Route Attribute - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Addins (https://forum.codeigniter.com/forumdisplay.php?fid=34)
+--- Thread: CodeIgniter4 Route Attribute (/showthread.php?tid=81283)



CodeIgniter4 Route Attribute - monkenWu - 02-12-2022

Hello everyone.

I designed a Library, which make CodeIgniter4 able to define routing settings of controllers through comments.

This library is a CodeIgniter4 Router presentative way under the PHP8 Attributes feature, it merely provides litte mapping and encapsulation for some CodeIgniter4 Router methods. 

By means of scanning the comments automatically inside the Controller, routes and methods will be connected, enables you to write routing rules straightforwardly, and maintain the relationship between Controllers and Routes in a convenient way.

Quick demo

PHP Code:
namespace App\Controllers;

use 
monken\Ci4RouteAttributes\Route;

class 
Ci4Controller extends BaseController
{
    #[Route(path: 'attr/route', methods: ["get"])]
    public function hello()
    {
        return "PHP8Attributes";
    }


Use the definition of  #[Route(path: 'attr/route', methods: ["get"])], means the same settings were done in your routing configuration:

PHP Code:
$routes->get('attr/route''App\Controllers\Ci4Controller::hello'); 


This library will smartly connect your controller and routing automatically, which means you can access to the hello method in Ci4Controller through the path of /attr/route.

If you are interested in this library, feel free to visit our Github repository to know how to install and use.

Thank you.


RE: CodeIgniter4 Route Attribute - InsiteFX - 02-13-2022

You mean like this, already done.

CodeIgniter4 Route Attribute


RE: CodeIgniter4 Route Attribute - luckmoshy - 02-13-2022

This i already have from
Code:
kenjis



RE: CodeIgniter4 Route Attribute - jillianmontague1 - 07-04-2022

(02-13-2022, 05:42 AM)luckmoshy Wrote: This i already  have from
Code:
kenjis cookie clicker

Need a more specific share