New Controller 404 Error

I apologize if this question seems basic, but I’ve been reading the Cookbook and struggling for hours and don’t understand why I can’t get a new controller to work. My understanding is that Controllers work similar to python flask routes, but maybe I’m mistaken. I just want to create a page and start building/learning off of that but no matter what I do, I just get error 404 when I try to load /test.

I have created a new project:
php composer.phar create-project --prefer-dist cakephp/app:4.* myapp

I created a file: src/Controller/TestController.php

and added the following code:

namespace App\Controller;

class TestController extends AppController
    public function index()

What kind of 404 do you get?
like, your webserver’s 404 or CakePHP’s big bad red telling you it’s missing the controller?

It’s been a while since I used create-project. Does that automatically do composer install for you, to get all the dependencies and autoloader installed in the vendor folder? If not, did you do that part?

@FinlayDaG33k got me thinking in the right direction. I was receiving the error from the webserver. For some reason, although I had already set “AllowOverride All” I had to do this:

sudo mv /etc/apache2/mods-available/rewrite.load /etc/apache2/mods-enabled/

Thanks for asking the right questions!

I believe you’re supposed to link files from mods-available into mods-enabled, not move them. A subsequent update to Apache might update the file for loading that module; a symlink would pick that change up, but a moved file won’t.