Standard
Standard

Reputation: 1512

Get Userfrosting / Slim to work with Controller Class

I'm completly new to the MVC pattern and I find it really hard to understand without programming, so I set up the Userfrosting Framework which is based on Slim. I followed this tutorial and I could see the default starting page, log in, etc.

Now I added a sprinkle called site, like in the tutorial and created a src directory in the sprinkle. But when I add a Controller class and a routing file, things get bad:

Callable UserFrosting\Sprinkle\Site\Controller\MainController does not exist

site/routes/mainRoutes.php:

<?php
$app->get('/', 'UserFrosting\Sprinkle\Site\Controller\MainController:getWelcome');

site/src/Controller/MainController.php:

<?php
namespace UserFrosting\Sprinkle\Site\Controller;
use UserFrosting\Sprinkle\Core\Controller\SimpleController;

class MainController extends SimpleController
{
    public function getWelcome($request, $response, $args)
    {

        return $response->write("Welcome to life");

    }
}

site/composer.json:

{ 
   ...
    "autoload": {
        "psr-4": {
            "UserFrosting\\Sprinkle\\Site\\": "src/"
        }
    }
}

How do I even start to find the problem? It's a really overwhelming topic.

Upvotes: 1

Views: 143

Answers (0)

Related Questions