0

I have a problem. I have installed CakePHP 3 using Ubuntu and I want to test the Router Prefix

Router::prefix('admin', function($routes) {
  $routes->connect('/:controller/:action/*', [], ['routeClass' => 'Cake\Routing\Route\InflectedRoute']);
});

I have followed the steps in the cookbook which I have this AppController and UsersController inside the /src/Controller/admin

src/Controller/admin/AppController.php

<?php
namespace App\Controller\Admin;

use Cake\Controller\Controller;


class AppController extends Controller{

public function initialize()
{
    parent::initialize();
    $this->loadComponent('Flash');
}


}// end class

?>

src/Controller/admin/UsersController.php

<?php
namespace App\Controller\Admin;

use Cake\Controller\Controller;


class AppController extends Controller{

public function initialize()
{
    parent::initialize();
    $this->loadComponent('Flash');
}


}// end class

?>

https://i.stack.imgur.com/7rjkv.png

I have already tried this scenario using XAMPP in Windows 8 and I've no problem. I really wonder if I miss something in the configuration?

By the way, I followed the steps on how to utilize cakephp 3 in ubuntu (from proper installing of LAMP, mbstring, intl, composer).

I will appreciate your answers. Thanks!

bowmeow
  • 109
  • 1
  • 11

1 Answers1

1

You haven't followed the steps described in the Cookbook exactly, the subnamespace starts with an uppercase letter, to be exact, it will use the CamelCapsed version of the prefix name, so in your case that's Admin, just like in the example.

If you look closely, that's also what the error message tells you

Error: Create the class UsersController below in file: src/Controller/Admin/UsersController.php

It works on Windows because by defaults its filesystem is case-insensitive.

Community
  • 1
  • 1
ndm
  • 59,784
  • 9
  • 71
  • 110