2
I tried to see if anyone had been through this problem but so far I haven’t found anything on the Internet. I’ve been trying to figure it out for two days and I’m almost giving up.
Directory
index.php
src/
|__Route/
| |__login.php
|__Dao/
|__UserDao.php
vendor/
Composer.json
"autoload": {
"psr-4": {
"Src\\": "src/"
}
}
Userdao.php
<?php
namespace Src\Dao;
class UserDao {}
Index.php
<?php
require_once 'vendor/autoload.php';
login.php
<?php
use Src\Dao\UserDao;
In my index.php works normally, everything is loaded. The problem arises when the form is submitted, arrives at login.php and launches the Fatal error: Uncaught Error: Class FILE not found.
Thank you in advance, in case anyone knows where I’m going wrong.
You added autoload require in arqivo login.php as well?
– Everton Neri
If you add it, it will work. But I thought it was just an autoload require. Cannot do with a single require in the file that will start the system?
– Daniel Chung
This would be possible if all requests passed through index.php. As your form redirects directly to the login.php file, you need to include autoload in it as well
– Everton Neri
It would be the concept of Frontcontroller
– Everton Neri
Got it, thanks for the feedback Everton.
– Daniel Chung