0

I have an annoying problem: I want to use GuzzleHttp\Client in my WP extension, but everytime I get an error:

"Fatal error: Class 'GuzzleHttp\Client' not found in /var/www/vhosts/localhost/htdocs/wp-content/plugins/myPlugin/classes/MyPlugin/Plugin.php on line..."

I have already checked out manipulations with Composer and Autoloader, in my composer.json:

"require": {
    "guzzlehttp/guzzle": "~6.0"
}

also I added into htdocs/index.php:

require( dirname( __FILE__ ) . '/../vendor/autoload.php');

but this didn't bring any changes. What did I do wrong? Thanks for your answers in advance!

4

1 回答 1

0

Sorry, I fogot to say that I used Guzzle in a Cronjob! So I added

require( dirname( __FILE__ ) . '/../vendor/autoload.php');

to the wp-cron.php file, because cron jobs don't involve index.php just at all.

于 2016-09-13T11:58:51.447 回答