Conversation
|
This has been raised before (#3). I still think the "solution" I proposed in that thread is the way to go - to change the "Docopt\docopt" function to be a static method of a "Docopt" class in the global namespace. Considering this has come up a couple of times, I'll have a look into cleaning the API up at the weekend. I remain hopeful that we'll get proper function autoloading in PHP one day, but I'm not holding my breath :( |
|
Still, even as a temp fix, changing your autoload directive to files fixes the issue. Without it, your composer.json file is near useless. |
|
It's true, it's useless if you're using Composer and want to use the Docopt\docopt() function which the README.rst file prescribes, but the $h = new \Docopt\Handler;
$options = $h->handle($usage);Or if you're on 5.4 or greater and you prefer one liners: $options = (new \Docopt\Handler)->handle($usage);I'll update the README to favour this method. |
|
Oh cool.... I hadn't really looked all that closely. Awesome. |
|
I hadn't actually realised I'd failed to document the autoloader friendly way of using docopt at all in the README until now. Rather silly of me. I've fixed it now. |
Unfortunately classmap won't work with this library as it only autoloads/maps classes. There are many functions sitting in the Docopt namespace that can't be autoloaded.
Using files fixes this by including src/docopt.php up front.