2
Hello, I really like php and for some time I’m using the concept of MVC in my application, but without using Composer and its autoloader. In search to elevate my knowledge, I installed the same and I came to use third party applications using dependencies.
The question is: where MY application is?
I read that you need to add the following code in my Composer.json
"autoload": {
"psr-4": {"MeuProjeto\\": "src/"}
}
But it still doesn’t work, I used the commands:
Composer update | Dump-autoload
and it didn’t work, what would be the problem? the mistake that gives is this:
Fatal error: Class 'Init' not found in C: Inetpub Estudo public index.php on line 33
But using the applications included in the project dependencies (within the vendor folder) no such error occurs thank you
Are you using the
namespace MeuProjeto;
in classInit
? Your class is inside the foldersrc/MeuProjeto
? Your application is in the foldersrc
, but if you install as a dependency, the application is normally invendor/author_user/package_name/src/namespace/*.php
– Valdeir Psr
@Valdeirpsr boy, did I forget to define the namespace? because the Init.php file was not itself a namespace, it was the initial access file that was redirected to the proper namespace... thank you!
– Everton Neri
And no, I added the code I found in the Poser documentation to my application to stay in the src folder (for my organization)
– Everton Neri
Blz. Managed to solve?
– Valdeir Psr
I did, buddy, thanks for your help!
– Everton Neri