Routing in cakephp 3.4


#1

hello guys i have a serious challenge here any any help would definately save my job. I encourage my boss to migrate to cake 3.4 from 2.X version. after a long discussion, he agreed. And I start working on it… All went well with the migration until routing stage. In version 2.4, to improve our SEO, we uses something like this in the routes.php
9:41
Router::parseExtensions();
Router::connect(
’/schools/show/:school_name’,
array(‘controller’ => ‘schools’, ‘action’ => ‘show’),
array(
‘pass’ => array(‘school_name’)
)
);
9:42
at the end we had this pattern www.mywebsite.com/schools/show/80/school_name:honeyland_college%2C_lagos.school
9:43
and all went well. To achieve the same this in cakephp 3,4 is a huge challenge to me. Now all links we have built over time with the above code in search engine takes users to error 404
9:44
how can i achieve the same pattern in cakephp 3
9:44
?


#2

this is my view.ctp <?php echo $this->Html->link($school->name,

array(

   'controller' => 'schools',

   'action' => 'show', $school->id,

   'school_name' => strtolower(preg_replace('/\s+/', '_', $school->'name)),

   'ext' => 'school'

  )

);

 ?>

#3

I have no specific answer to your problem but, this is how the routing works in 3.x

/**
* …and connect the rest of ‘Pages’ controller’s URLs.
/
$routes->connect(’/pages/
’, [‘controller’ => ‘Pages’, ‘action’ => ‘display’]);

/**
 * Connect catchall routes for all controllers.
 *
 * Using the argument `DashedRoute`, the `fallbacks` method is a shortcut for
 *    `$routes->connect('/:controller', ['action' => 'index'], ['routeClass' => 'DashedRoute']);`
 *    `$routes->connect('/:controller/:action/*', [], ['routeClass' => 'DashedRoute']);`
 *
 * Any route class can be used with this method, such as:
 * - DashedRoute
 * - InflectedRoute
 * - Route
 * - Or your own route class
 *
 * You can remove these routes once you've connected the
 * routes you want in your application.
 */

for more detail: https://book.cakephp.org/3.0/en/development/routing.html