Problems with my own plugin - CakePhp 3

1

I'm using Cakephp 3 and I created a plugin called Intranet using bake :

bin/cake bake plugin Intranet

This created the structure in:

  

project / plugins / Intranet

Then I created a controller called Products :

bin/cake bake controller --plugin Intranet Products

In the file config/bootstrap.php of the project I added the following:

Plugin::load('Intranet', ['bootstrap' => false, 'routes' => true]);

In config/routes.php :

Plugin::routes();

In the file proyecto/plugins/Intranet/config/routes.php I have the following:

Router::plugin(
    'Intranet',
    ['path' => '/intranet'],
    function (RouteBuilder $routes) {
        $routes->fallbacks(DashedRoute::class);
    }
);

In proyecto/plugins/Intranet/composer.json :

"autoload": {
    "psr-4": {
        "Intranet\": "src"
    }
},
"autoload-dev": {
    "psr-4": {
        "Intranet\Test\": "tests",
        "Cake\Test\": "./vendor/cakephp/cakephp/tests"
    }
}

When I access http://site/intranet/products/index I get the error:

  

A route matching "array ('controller' = > 'users', 'action' = >   'login', 'prefix' = > 'admin', '_mobile' = > false, 'preview' = > false,   'plugin' = > 'Intranet', '_ext' = > NULL,) "could not be found.

How do I identify the error? I have tried some things, how to put:

Plugin::load('Intranet', ['autoload' => true, 'bootstrap' => false, 'routes' => true]);

... and so on all its variants. I also tried to put the path from the file routes.php of the project, I executed the commands:

composer update y composer dumpautoload

No results. The only different error was:

  

Controller class Products could not be found

    
asked by Sandra VR 05.12.2016 в 14:03
source

1 answer

0

When you create the controller, use the conventions of cake

bin/cake bake ProductsController --plugin Intranet Products

Inside the controller did you create the index function?

public function index(){

echo "esta es mi pagina intranet";
}
    
answered by 06.12.2016 в 01:39