Is it possible to require only 1 file from a composer package?
I need only 1 or few files from a package and it would be pointless to require the whole package which consist of hundred of files when i would use only a few.
Is it possible to do this via composer?
It's possible to include specific files in the current package with the files
autoloading strategy:
{
"autoload": {
"files": [
"path/to/my/file.php"
]
}
}
If you need to require specific files from a package you installed with composer, this is not possible. Not really needed either, as the files are not loaded into memory unless you use them in your code.
More about files and other autoloading stragegies can be found in the composer docs.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With