R
R
Romi2021-11-15 13:40:55
Composer
Romi, 2021-11-15 13:40:55

Is it necessary to write the Composer package namespace ("autoload") by hand in the composer.json of the main application?

I decided to make a module for Laravel in the form of a Composer package.

I install from a local repository (folder). Everything is installed, but for some reason it then starts looking for a class, don’t understand where at all:

Go3Y6Z4.png

Moreover, if I write it in the main composer.json of the application (at the root of Laravel)

"autoload": {
        "psr-4": {
            "MeVendor\\Hello\\": "packages/mevendor/hello/src/"
        }
    },


then it sees everything perfectly and works.

But isn't that right? Because I already wrote this to him in the composer.json of the package . He is supposed to copy from there, right?

I understand that he is missing something, but I don’t understand what exactly :)

Help please, who has come across this rake -)

And yes, here is the composer.json of the package:

{
    "name": "mevendor/hello",
    "description": "Hello package!",
    "type": "project",
    "license": "MIT",
    "authors": [
        {
            "name": "mevendor",
            "email": "[email protected]"
        }
    ],
    "minimum-stability": "dev",
    "autoload": {
        "psr-4": {
            "MeVendor\\Hello\\": "src/"
        }
    },
    "require": {}
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Romi, 2021-11-15
@romicohen

In general, the fact was that I launched Composer in the Host system, and I run Laravel in Docker Compose :-)
After installing the package through Composer, which is in the container, everything showed up by itself and began to work fine ))
I, with your permission I will not delete this topic - I will leave it as a monument to my own stupidity)))) What if someone else steps on this rake :)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question