Use composer to require only 1 file?

Is it possible to require only one file from the composer package?

I only need 1 or more files from the package, and it would be pointless to require the entire package, which consists of hundreds of files, when I use only a few.

Can this be done with the help of a composer?

+4
source share
1 answer

You can include certain files in the current package using the filesstartup strategy :

{
    "autoload": {
        "files": [
            "path/to/my/file.php"
        ]
    }
}

If you need to require certain files from the package that you installed with the composer, this is not possible. It is also not required, since files are not loaded into memory if you do not use them in your code.

.

+3

Source: https://habr.com/ru/post/1628484/


All Articles