I'm creating a test framework. I use composer to create the structure of my project. The composer.json file looks like this:
{
"autoload": {
"psr-4": {
"App\": "src/app/mvc/"
}
}
}
I divided my project with the following structure:
C: \ xampp \ htdocs \ webApp \ src \ app \ mvc \
In mvc I have the following subfolders: controller; model; view
Being that I'm having problems in the namespace.
For example for /model/model.php the code was:
<?php
namespace App;
class Model
{
public function getText($str = 'Olá mundo!')
{
return $str;
}
}
For the controller / controller.php the code was:
<?php
namespace App\controller;
class Controller
{
public function index()
{
$model = new model\Model;
$view = new view\View;
$view->render($model->getText());
}
}
The php is returning an error in controller.php Fatal error: Class 'App \ controller \ model \ Model' not found in C: \ xampp \ htdocs \ webApp \ src \ app \ mvc \ controller \ Controller.php on line 7
Someone would know what's wrong with the psr4 setup.