CodeIgniter Forums
Can named routes be auto generated for restful routes created with $route->resource() - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: Can named routes be auto generated for restful routes created with $route->resource() (/showthread.php?tid=79130)



Can named routes be auto generated for restful routes created with $route->resource() - Polymorphism - 04-26-2021

I'm currently testing out CI4 and I wanted to know if there is a way to generate named routes when creating restful routes.

Here is an example:

PHP Code:
// Calling this:
$routes->resource('task');

// auto-generates:
['as' => 'tasks'// for TaskController::index
['as' => 'show_task'// for TaskController::show
['as' => 'create_task'// for TaskController::create
// etc... 
I know I can create it manually, but is a form of auto generation available?


RE: Can named routes be auto generated for restful routes created with $route->resource() - paliz - 04-26-2021

Hi when use restfull api mean backend and frontend are separate and pretty url it dosen matter for backend. But front can be anthing vue react angular and so on so you have manage url for front end

Oky