1. Go to this page and download the library: Download kenjis/ci4-attribute-routes library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
kenjis / ci4-attribute-routes example snippets
use Kenjis\CI4\AttributeRoutes\Route;
class SomeController extends BaseController
{
#[Route('path', methods: ['get'])]
public function index()
{
...
}
}
/*
* Attribute Routes
*
* To update the route file, run the following command:
* $ php spark route:update
*
* @see https://github.com/kenjis/ci4-attribute-routes
*/
if (file_exists(APPPATH . 'Config/RoutesFromAttribute.php')) {
namespace App\Controllers;
use Kenjis\CI4\AttributeRoutes\Route;
class News extends BaseController
{
#[Route('news', methods: ['get'])]
public function index()
{
...
}
}