cakephp difference between Router::scope and Router::prefix -
i know router's prefix method adds prefix routes still confused scope method routes.is alias prefix or has own use.
router::prefix('api', function ($routes) { $routes->scope('/v1', function ($routes) { $routes->connect('/', ['action'=>'index']); $routes->connect('/:id', ['action'=>'view', ':id']); }); });
both allow sharing of common path segments. difference prefix controller within sub-namespace.
from documentation:
prefixes mapped sub-namespaces in application’s controller namespace ... using our users example, accessing url
/admin/users/edit/5
calledit()
method of oursrc/controller/admin/userscontroller.php
passing 5 first parameter. view file usedsrc/template/admin/users/edit.ctp
in above case, scope controller @ src/controller/userscontroller.php
.
Comments
Post a Comment