Welcome Guest, Not a member yet? Register   Sign In
CodeIgniter4 Route Attribute
#1

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.
Reply
#2

You mean like this, already done.

CodeIgniter4 Route Attribute
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#3

This i already have from
Code:
kenjis
Do Codeigniter Before Do You!
yekrinaDigitals

Reply
#4

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

Need a more specific share
Reply




Theme © iAndrew 2016 - Forum software by © MyBB