I am trying to use prefix routing in CakePHP3. I added the following lines to /config/routes.php.
Router::prefix("admin", function($routes) {
// All routes here will be prefixed with ‘/admin‘
// And have the prefix => admin route element added.
$routes->connect("/",["controller"=>"Tops","action"=>"index"]);
$routes->connect("/:controller", ["action" => "index"]);
$routes->connect("/:controller/:action/*");
});
After that, I created /src/Controller/Admin/QuestionsController.php like below.
<?php
namespace App\Controller\Admin;
use App\Controller\AppController;
class QuestionsController extends AppController {
public function index() {
//some code here
}
}
?>
Finally I tried to access localhost/app_name/admin/questions/index
, but I got an error saying, Error: questionsController could not be found
. However, when I capitalize the first letter of controller name(i.e. localhost/app_name/admin/Questions/index), it is working fine. I thought it is weird because without prefix, I can use controller name whose first character is not capitalized.
Is this some kind of bug?