M
M
My joy2017-05-23 19:29:03
PHP
My joy, 2017-05-23 19:29:03

Composer autoload your namespace?

Guys hello. I'm doing a new project, I decided to use autoload from composer. But I can't get my head around his logic. You need to add the namespace "App" so that the loader looks for it in the "app/classes" folder (app is on the same level as the vendor)
in composer.json wrote like this:

"psr-0": {
            "App\\": "../app/classes/"
        }

In the classes folder there is a Rooms file that starts like this:
namespace App;
class Rooms {
...

And at the main level (on the same level as the vendor) is index.php in which I try to use Rooms:
use App;
echo Rooms::test();

I see the message "The use statement with non-compound name 'App' has no effect in"
Tell me how in my case I need to set the path to the app / classes folder so that the namespace App is responsible for this folder.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Aksentiev, 2017-05-23
@Sanasol

use App\Rooms;
should probably indicate

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question