I've made packages for NPM and I know the drill there. You simply list your dependencies and then require()
them. Node searches node_modules
, finds the package, loads it and you're good to go.
How does that work in PHP, though? My dependency is PoParser. I know I can just do:
require __DIR__ . '/vendor/autoload.php';
But when I publish my package, I wouldn't publish the third party dependency code, right? My package should only contain my code. At least that's the case with NPM.
So if I don't have that vendor
folder when I publish my thing. How would I require my dependency? In Node, require()
does that hard work. How would I do it here?
Here's my folder structure, if that helps:
vendor
/composer
...
/sepia
/po-parser
...
/src
/Sepia
...
// dependency classes
...
...
autoload.php
composer.json
composer.lock
MyThing.class.php
Other.class.php