client-php
client-php copied to clipboard
composer fails to autoload the class
I'm using (or rather trying to) implement everything that client-cli does, except... well, without the cli part.
I have pretty much everything working. Here's my composer.json
file:
{
"name": "javorszky/wp-oauth1",
"description": "My feeble attempt at an oauth1 client",
"require": {
"wp-api/client": "dev-master",
"rmccue/requests": "~1.6",
"justinrainbow/json-schema": "dev-master",
"markjaquith/wp-tlc-transients": "*"
}
}
Everything installs fine. I'm trying to instantiate a new WPAPI;
, but I get the error Fatal error: Class 'WPAPI' not found in /file.php line 1
The path to the file is: vendor/wp-api/client/library/WPAPI.php
.
I tried to follow the flow in vendor/composer/ClassLoader.php
, and while WPAPI
is getting passed there, none of the tries match the file it would be in.
I'm not even sure this is an issue of WPAPI or composer, or a combination of, or I'm doing it wrong(:tm:)
Where do I start to debug this?
This is the reduced test case: https://github.com/javorszky/composer-vs-wpapi
Solved. I think.
In my composer.json
file, this is needed:
"autoload": {
"psr-0": {
"": "vendor/wp-api/client/library"
}
}
or alternatively this:
"autoload": {
"classmap": ["vendor/wp-api/client/library"]
}
Doesn't seem to matter which one. The question is: why does WPAPI
work with https://github.com/WP-API/client-cli given that there's no autoload
prop in that composer.json
file?
(Not closing this as I'd like some eyes on this whether this is indeed the solution, or I just happened to make it work for the time being with the help of others.)