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 call edit() method of our src/controller/admin/userscontroller.php passing 5 first parameter. view file used src/template/admin/users/edit.ctp

in above case, scope controller @ src/controller/userscontroller.php.


Comments

Popular posts from this blog

html - Firefox flex bug applied to buttons? -

html - Missing border-right in select on Firefox -

c# - two queries in same method -