CodeIgniter Forums
Help with RESTful Resource Routes - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30)
+--- Thread: Help with RESTful Resource Routes (/showthread.php?tid=81547)



Help with RESTful Resource Routes - castle - 03-16-2022

Hi,


Reading REST Resource Naming Guide item 2.4. Never use CRUD function names in URIs, I noticed that the example on the CI4 documentation doesn't follow that. Did I understand correctly? Am I missing something?


Thanks.


RE: Help with RESTful Resource Routes - sba - 03-16-2022

$routes->resource('photos'); from documentation does that, what your link to REST Guide says it should do (use HTTP request methods)
But with codeigniter you can also easy do eg. deletion with uri segements, like $routes->post('photos/(Confusedegment)/delete' - it depends on the application, personally I don't think its completly wrong this way.


RE: Help with RESTful Resource Routes - castle - 03-16-2022

(03-16-2022, 08:51 AM)sba Wrote: $routes->resource('photos'); 
But the CI documentation has a controller route "photos/(Confusedegment)/edit". That doesn't follow the Restful guide, does it?


RE: Help with RESTful Resource Routes - kenjis - 03-17-2022

You're correct.

Strictly speaking,
PHP Code:
photos/(:segment)/edit 
is not needed in REST API.

You can remove the edit:
https://codeigniter.com/user_guide/incoming/restful.html#id3


RE: Help with RESTful Resource Routes - castle - 03-17-2022

(03-17-2022, 01:04 AM)kenjis Wrote: You're correct.

Strictly speaking,
PHP Code:
photos/(:segment)/edit 
is not needed in REST API.

You can remove the edit:
https://codeigniter.com/user_guide/incoming/restful.html#id3

Ok. Thank you.