I was just creating one of my first PHP Packages using Composer and I hit a problem.
Currently I'm working on a package that his main class extends a class from another package, so on my composer.json
I've the package I'm extending declared as a requirement:
"require": {
"php": ">=5.3.0",
"ext-mbstring": "*",
"author/BasePackage": "dev-master"
},
And, If I issue composer update
I get a nice vendor
directory inside my project with the author/BasePackage
dependency downloaded there.
So my question is, on my main class file src\Extended.php
I need to manually do something like require_once __DIR__ . "/../vendor/autoload.php";
in order to autoload the BasePackage
so I can do class Extended extends \BasePackage\BasePackage
.
Is this ok? How am I supposed to load my package dependencies? When I commit this package to GitHub or so, I'm ignoring the vendor
directory and if someone uses this by requiring it on their projects require_once __DIR__ . "/../vendor/autoload.php";
will fail because it won't be where I expected it to be.
How should I do this?
Thank you.