# Basic routing problem with plugins

**URL:** <https://discourse.cakephp.org/t/basic-routing-problem-with-plugins/1102>\
**Category:** Need Help\
**Created:** [September 3, 2016, 4:45pm UTC](https://discourse.cakephp.org/t/basic-routing-problem-with-plugins/1102 "2016-09-03T16:45:51Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![chief-cook](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/chief-cook/32/479_2.png) [@chief-cook](https://discourse.cakephp.org/u/chief-cook)\
**Post date:** [September 3, 2016, 4:45pm UTC](https://discourse.cakephp.org/t/basic-routing-problem-with-plugins/1102/1 "2016-09-03T16:45:51Z")

</div>

Hey there!  
I am pretty new to CakePHP and after I spent so many hours on this issue without an answer I hope somebody can help me here.

I want to call a view of my plugin from another view of my main page by clicking on a link which looks like this:

`<li><?= $this->Html->link(__('Postal Services'), ['plugin' => 'MailCalculator', 'contoller' => 'postal_services', 'action' => 'index']) ?></li>`

But after I click the link I always get the same exception:

**Error: Create the class PagesController below in file: /Applications/MAMP/htdocs/rich-code/plugins/MailCalculator/src/Controller/PagesController.php**

And the address line in my browser looks like this:  
[http://localhost/rich-code/mail\_calculatorpages?contoller=postal\_services](http://localhost/rich-code/mail_calculatorpages?contoller=postal_services)

the code in my config/routes.php:  
Router::defaultRouteClass(DashedRoute::class);

```
Router::scope('/', function (RouteBuilder $routes) {

    $routes->connect('/', ['controller' => 'Pages', 'action' => 'home']);

    $routes->fallbacks('DashedRoute');
});

```

(I’m still not sure if this is enough, but all of my PagesController’s actions are perfectly accessible from my homepage so far. Somehow it builds the path automatically, e.g. [http://localhost/rich-code/pages/about](http://localhost/rich-code/pages/about) when I call the about() action without me being forced to add a routes-\>connect rule like $routes-\>connect(’/pages/\*’, …)

And the code in my plugin’s config/routes.php:  
\<?php  
use Cake\Routing\Router;

```
Router::plugin('MailCalculator', function ($routes) {
    $routes->fallbacks('DashedRoute');
});

Router::scope('/mail_calculator', ['plugin' => 'MailCalculator'], function ($routes) {
    $routes->connect('/insurance', ['controller' => 'PostalServices']);
    $routes->connect('/insurance/:action/*', ['controller' => 'PostalServices']);
});

```

I tried millions of ways to handle it but no matter what I do, CakePHP insists on appending the pages bit to every of my paths: **pages?contoller** after the plugin name

Could anybody guide me through here a bit because I’m completely lost

---

<div class="post-metadata">

**Author:** ![Salines](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/salines/32/3166_2.png) [@Salines](https://discourse.cakephp.org/u/Salines)\
**Post date:** [September 4, 2016, 8:04am UTC](https://discourse.cakephp.org/t/basic-routing-problem-with-plugins/1102/2 "2016-09-04T08:04:50Z")

</div>

> [@chief-cook](#):
>
> **‘contoller’** =\> ‘postal\_services’,

// would be ‘controller’

---

<div class="post-metadata">

**Author:** ![chief-cook](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/chief-cook/32/479_2.png) [@chief-cook](https://discourse.cakephp.org/u/chief-cook)\
**Post date:** [September 4, 2016, 8:40am UTC](https://discourse.cakephp.org/t/basic-routing-problem-with-plugins/1102/3 "2016-09-04T08:40:21Z")

</div>

Wow!  
Thank you so much!
