I was previously using mailchimp ver 3x. I updated to version 4x and some errors started popping up. I disabled the module and un-installed the module and deleted mailchimp library.
I downloaded new library and installed version 4x again but after enabling the module I get this error.
Fatal error: Class 'GuzzleHttp\Client' not found in /home/xxxx/public_html/sites/all/libraries/mailchimp/src/Mailchimp.php on line 97

I tried to look online for similar issue and even installed composer and guzzle but the error still persists.

Any ideas?

Members fund testing for the Drupal project. Drupal Association Learn more

Comments

konrad_u created an issue. See original summary.

ruscoe’s picture

Could you run composer install inside /home/xxxx/public_html/sites/all/libraries/mailchimp/, clear your cache and try reloading?

konrad_u’s picture

hey @ruscoe

I'm reporting that that fixed the issue (as of writing: current presidential results in NY did not :) )

I'll let you check whether that's Closed (works as designed) or needs looking into.

Thank you for your help,

ruscoe’s picture

Status: Active » Closed (works as designed)
funkycamel’s picture

Hi,

Got the same error after saving the api key on the mailchimp module settings but I am kinda stuck. How can I "run composer install inside /home/xxxx/public_html/sites/all/libraries/mailchimp/"?

I would appreciate it if you provide detailed instructions.

Thanks in advance

funkycamel’s picture

Status: Closed (works as designed) » Active

I am just reopening this cause I am not sure if you will see/respond to my comment. If this is not a good practice please let me know (and of course, I apologise about it).

Thanks

konrad_u’s picture

hey @funkycamel

It's totally okay to reopen since that now seems like composer is a dependency which should be included in a documentation...
If you know how to use SSH you just have to cd to the proper directory and run:

# Install Composer
curl -sS https://getcomposer.org/installer | php

# Add Guzzle as a dependency (not sure if this is required)
php composer.phar require guzzlehttp/guzzle:~6.0
ruscoe’s picture

Hi @funkycamel, it's definitely ok for you to reopen a ticket if you're having a problem.

There is some information in the installation notes, but I agree it could be made clearer.

@konrad_u has it right in comment #7.

If you are hosting on a Linux server and you are able to connect to it via SSH, you can run these commands:

cd /path/to/your/site/sites/all/libraries/mailchimp
curl -sS https://getcomposer.org/installer | php
./composer.phar install

Composer will create a directory named "vendor" inside the mailchimp library directory. This is where the GuzzleHttp library will be.

If you aren't able to connect via SSH, and use FTP to upload files to your site, you can run composer locally then use FTP to upload the directory it creates.

If you're using a Linux or OSX computer, you can run the same commands as above, just replace the path with the local path to your site files. Then you would need to upload the mailchimp library via FTP.

If you're using a Windows computer, I believe you can still use Composer as above. I haven't tried it, but there's a Windows version.

That should fix it for you. Please do update this ticket and let me know if that doesn't help.

funkycamel’s picture

Hi again,

Thanks for getting back to me so quickly! So, I tried the following through ssh (using ubuntu and the hosting is shared - siteground):

/sites/all/libraries/mailchimp]# curl -sS https://getcomposer.org/installer | php ./composer.phar install
Could not open input file: ./composer.phar
curl: (23) Failed writing body (0 != 16133)

/sites/all/libraries/mailchimp]# curl -sS https://getcomposer.org/installer | php
Some settings on your machine make Composer unable to work properly.
Make sure that you fix the issues listed below and run this script again:

The detect_unicode setting must be disabled.
Add the following to the end of your `php.ini`:
detect_unicode = Off

The php.ini used by your command-line PHP is: /usr/local/php53/lib/php.ini
If you can not modify the ini file, you can also run `php -d option=value` to modify ini values on the fly. You can use -d multiple times.

/sites/all/libraries/mailchimp]# php ./composer.phar install
Could not open input file: ./composer.phar
/sites/all/libraries/mailchimp]# php composer.phar require guzzlehttp/guzzel:~6.0
Could not open input file: composer.phar
/sites/all/libraries/mailchimp]# curl -sS https://getcomposer.org/installer | php ./composer.phar install
Could not open input file: ./composer.phar
curl: (23) Failed writing body (0 != 16133)

So, now do I need to run something like php -d detect_unicode=off and then php composer.phar require guzzlehttp/guzzle:~6.0 or curl -sS https://getcomposer.org/installer | php
./composer.phar install from scratch
?
If yes, will this might cause any side effects to anything else related to my website ?

Sorry, but I am still a noob on ssh and bash commands...

funkycamel’s picture

FileSize
59.61 KB

As It seems so, shared hosting account holders cannot edit settings on /usr/local/php53/lib/php.ini (or at least at siteground)

Their support suggested to run the following (placing as well the output):

curl -s https://getcomposer.org/installer | php -d detect_unicode=Off
Some settings on your machine may cause stability issues with Composer.
If you encounter issues, try to change the following:

PHP was compiled with --with-curlwrappers which will cause issues with HTTP authentication and GitHub.
Recompile it without this flag if possible

Downloading 1.0.2...

Composer successfully installed to: /home/maltahom/public_html/sites/all/libraries/mailchimp/composer.phar
Use it: php composer.phar
 [~/public_html/sites/all/libraries/mailchimp]# php composer.phar install
 [~/public_html/sites/all/libraries/mailchimp]# 

Before, the website was not loading at all but when I deactivated and reactivated the modules through drush it seems to be fine. After running the above and clearing the cache from the cpanel, I only get the error whenever I try to flush the cache memories through the admin menu selection. Furthermore, although on the modules page I get the selections Permissions and Settings for the campaigns and sign up, on the mailchimp page (Home » Administration » Configuration » Web services » MailChimp) I do not see any options (see attachment).

Have I done something wrong (or anything right :p)?

lazzyvn’s picture

hello
how can i use run composer on hosting 1and1 i can access ssh but i can't run composer
i down from instruction i got
autoload.php
doctrine
phpspec
sebastian
bin
guzzlehttp
phpunit
symfony
composer
phpdocumentor
psr

i copy only guzzlehttp or all lib?

ruscoe’s picture

@funkycamel You're on the right track, but I would expect to see more output from running php composer.phar install.

Did Composer create a new "vendor" directory inside libraries/mailchimp/?

ruscoe’s picture

@lazzyvn You can copy all of those files to your web server. They should be copied to a directory named "vendor" inside the MailChimp library directory. The structure would look like this:

libraries
  - mailchimp
    - vendor
      - autoload.php
      - doctrine
      - phpspec
      - sebastian
      - bin
      - guzzlehttp
      - phpunit
      - symfony
      - composer
      - phpdocumentor
      - psr
funkycamel’s picture

No, It did not. The contents of the mailchimp library folder are the following:

src(folder)
tests(folder)
.gitignore
README.md
composer.json
composer.phar
phpunit.xml

ruscoe’s picture

Could you run php composer.phar install --verbose and post the result?

The --verbose part should get Composer to tell us about any problems.

konrad_u’s picture

To all of those experiencing issues on shered hosting keep in mind that you can install stable mailchimp version 3 which doesn't require composer

funkycamel’s picture

FileSize
193.62 KB

Not much besides some weird chars in the beginning of the line(see attachment).

For the sake of it, I removed everything and tried it from scratch. During the deactivation of the modules, I first deactivated Activity, Campaigns and Signup (it does not allow me in the first step mailchimp and Lists since they are required from the rest). I got the error, I hit F5 and confirmed form resubmission on the browser and I realised that It deactivated the Lists as well. The sequence on the uninstallation was as expected.

After doing everything as indicated in the readme file and saving the API key and got the same behaviour as before...

verbose has again the same output.

Greg Boggs’s picture

Wow, that's a funny message. Go ahead and try reinstalling composer.

curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer

which composer should return /usr/local/bin/composer

funkycamel’s picture

******* [~/public_html/sites/all/libraries/mailchimp]# curl -sS https://getcomposer.org/installer | sudo php -d detect_unicode=off -- -- install-dir=/usr/local/bin -- filename=composer
-bash: sudo: command not found
curl: (23) Failed writing body (0 != 16133)
****** [~/public_html/sites/all/libraries/mailchimp]# curl -sS https://getcomposer.org/installer | sudo php -- -- install-dir=/usr/local/bin -- filename=composer
-bash: sudo: command not found
curl: (23) Failed writing body (0 != 16133)

Most likely cause it is shared hosting. I do not even see the directory /usr.

Should I assume that the new library was built by having in mind that the drupaler has full server access?

Greg Boggs’s picture

You should be running these commands on your local environment. Not on your shared hosting. You can then upload the results to shared hosting.

Greg Boggs’s picture

You could, of course, run these commands in shared hosting without su... but I wouldn't recommend editing files live on production. It's best to always work on your Drupal site in a local environment and then deploy the results.

ruscoe’s picture

I see from your screenshot that you're using Ubuntu. You could run the composer commands locally, where you have full access, then FTP the vendor directory up to your web server.

You should be able to run these commands individually (swapping out the path for your own local path):

cd /users/your_user/path/to/files/sites/all/libraries/mailchimp/
curl -s https://getcomposer.org/installer | php
php composer.phar install
ls -la

After the last command, you should see the vendor directory that should be copied to the corresponding library directory on your web server.

Gregg's comment (#18) explains how to install Composer globally, so you wouldn't need to download it using curl. You could do that on your local Ubuntu installation to save time using Composer in the future.

funkycamel’s picture

It seemed to worked. I did not get any errors and I ended up uploading 1350 files. Does it sound correct?

I activated the modules and now I get the following error and the website is unavailable

Parse error: syntax error, unexpected '[', expecting ')' in /home/*******/public_html/sites/all/libraries/mailchimp/vendor/guzzlehttp/promises/src/functions.php on line 41

Should I open another issue?

Thank you Greg Boggs, ruscoe and Konrad_u for the suggestions and patience!

ruscoe’s picture

Sounds like you might be using PHP 5.3. If you can upgrade to PHP 5.4, that should work. There will likely be an option to upgrade through your host's control panel.

lazzyvn’s picture

i confirm #13 works fine on my hosting

funkycamel’s picture

I switched to 5.4.45 and error vanished. But I know got another one once I click on the settings of the campaigns and lists.

Fatal error: Call to undefined function GuzzleHttp\Handler\curl_reset() in /home/maltahom/public_html/sites/all/libraries/mailchimp/vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php on line 78

I found out here that this specific function requires PHP 5.5.

So I switched again the PHP version to 5.5.33 and everything seem to work.

Closing the issue. Thanks again!

funkycamel’s picture

Status: Active » Closed (works as designed)
criscom’s picture

#8 fixed it fo me.

tinkererer’s picture

# Install Composer
curl -sS https://getcomposer.org/installer | php

# Add Guzzle as a dependency (not sure if this is required)
php composer.phar require guzzlehttp/guzzle:~6.0

Fixed it for me. Dedicated hosting FWIW.

stpaultim’s picture

Status: Closed (works as designed) » Active

I'm having the same problem demonstrated in #26 on a site hosted on shared hosting with GoDaddy (not my choice). Highest available version of PHP is 5.4

Fatal error: Call to undefined function GuzzleHttp\Handler\curl_reset() in /home/content/88/10000088/html/sites/all/libraries/mailchimp/vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php on line 78

I found the same note suggesting that curl_reset may require php 5.5. Is php 5.5 a requirement for MailChimp 7.x-4?

In the meantime, it seems like I'll need to downgrade to an earlier version of MailChimp.

Greg Boggs’s picture

The unsupported version of the module will continue to function without security coverage until MailChimp discontinues their v2 API. After that, if GoDaddy hasn't upgraded your plan to secure PHP, you'll either need to upgrade to GoDaddy cPanel hosting or switch providers.

https://www.godaddy.com/help/software-versions-shared-hosting-897

Greg Boggs’s picture

Hi Folks,

Great news for y'all stuck with Go Daddy, or expired PHP, we've added support for PHP 5.4 to the latest release of Mailchimp 7.x

New MailChimp release:

https://www.drupal.org/project/mailchimp/releases/7.x-4.7

You need both the updated module and library (both had PHP 5.5 code)

New lib: https://github.com/thinkshout/mailchimp-api-php/releases/tag/v1.0.5

Greg Boggs’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

blazemongr’s picture

The update isn't working for me, unfortunately. Running PHP 5.4.45, and after installing https://github.com/thinkshout/mailchimp-api-php/releases/tag/v1.0.5 and updatng the module to 4.7:

> The MailChimp PHP library is missing the required GuzzleHttp library. Please check the installation notes in README.txt.

Running on Ubuntu

Begun’s picture

I am also having issue with this. I have tried installing the mailchimp library via composer and have also tried using the package containing the dependencies. In both cases it fails. Keep getting `WD mailchimp: The MailChimp PHP library is missing the required GuzzleHttp library. Please check the installation notes in README.txt.` error.

The site is running on Acquia cloud.
PHP version: 5.6
Mailchimp module: 7.x-4.7
Mailchimp PHP library: v1.0.5

Begun’s picture

Just discovered the cause of the issue (#36). Turns out `vendor` directory was being excluded from git repo was not being deployed.

Danny Englander’s picture

I just ran into this issue as well, "The MailChimp PHP library is missing the required GuzzleHttp library". I cd'd to the mailchimp folder in libraries and ran composer install but it installs an entirely different structure than that mentioned in #13.

After install, inside /sites/all/libraries/mailchimp/vendor/, I have

  • andrewsville
  • apigen
  • bin
  • composer
  • dg
  • kukulich
  • nette
  • autoload.php

So I am not sure that I am doing wrong.

Greg Boggs’s picture

Maybe try downloading the prebuilt Library?

Danny Englander’s picture

Oh yes, I missed that. That seems to fix it. Thanks!

b_willems’s picture

Winging in to say thanks for the advice on downloading the prebuilt Library -- I too had issues with composer on one clients server.

Also Greg FYI in #32 you say that the latest version, 4.7, will run with PHP 5.4. I have a client on a host stuck on 5.4 and tried to update them to that version. The update.php script gave me an error saying 5.5 was required.

chrisloos’s picture

If anyone else is:

  1. encountering this problem on their remote environment but not their local environment
  2. deploying to remote via git

Try modifying mailchimp/.gitignore and remove the following line:

/vendor

Then add/commit/push/pull. This fix worked for me.

therobyouknow’s picture

Thank you chrisloos in comment 42 - I found that to solve the issue.

If anyone else is:

encountering this problem on their remote environment but not their local environment
deploying to remote via git
Try modifying mailchimp/.gitignore and remove the following line:

/vendor

Then add/commit/push/pull. This fix worked for me.

dfmjr’s picture

#42 solved this for me! Thanks chrisloos

https://www.drupal.org/node/2709615#comment-11888769

flux423’s picture

Built a quick patch to help anyone that needs it. This removes the /vendor folder from the .gitignore file.

OPS. Wrong patch. I'll upload another.

flux423’s picture

Here is the new patch.

dpico’s picture

Hi.

I'm a bit desperate with this error. I've tried the different solutions explained here, in particular #42 and #46 and the Guzzle error keeps popping up. I've deleted the Mailchimp module and all traces of if, including all references to "mailchimp" in the database, I've reinstalled it (module and libraries), and the error pops up again. Cleared caches, updated database, etc. Nothing. This site had a previous Mailchimp 3.x install.

Is it possible that there is some old information in the database that is confusing the module? Or another module that is interfering with this?

therobyouknow’s picture

dpico - please check that you actually have the file that the Guzzle error is complaining is missing.

i.e. the original error is:
Fatal error: Class 'GuzzleHttp\Client' not found in /home/xxxx/public_html/sites/all/libraries/mailchimp/src/Mailchimp.php on line 97

So check that you have the vendor folder with the Guzzle library within it.

The fix in #42 fixes the issue when you are committing your code to the repo and deploying this repo on another server, e.g. your production server. The fix makes sure that the /vendor folder is not ignored by git when you commit to the repo so that it is therefore included in the repo. Then, when it comes to deploying this repo on another server, that server will have the /vendor folder and the Guzzle library within it.

Please tell us more about:
- what you have before you do #42 in terms of code, and if you already have the /vendor folder and code in your code OR if you don't have it
- what you do after you've done step #42

I'm wondering if you are doing #42 on the machine where you are seeing the problem - if the /vendor folder is not there then the #42 won't fix it, you have to have done #42 when committing code that already has /vendor and then deploying it to the server that your site runs on.

dpico’s picture

Thanks for your help!

At this moment, I don't have #42. I'm on a shared server and I installed the precompiled libraries from https://github.com/thinkshout/mailchimp-api-php/files/710410/v1.0.6-pack.... I also applied the patch in #46, just in case, but I didn't add/commit/push/pull on git. I have this:

$ cat .gitignore
/composer.lock
.idea

And the sites/all/libraries/mailchimp folder contains:

.
├── .gitignore
├── .travis.yml
├── composer.json
├── composer.lock
├── CONTRIBUTING.md
├── phpunit.xml
├── README.md
├── src
│   ├── MailchimpAPIException.php
│   ├── MailchimpAutomations.php
│   ├── MailchimpCampaigns.php
│   ├── MailchimpCURLClient.php
│   ├── MailchimpEcommerce.php
│   ├── MailchimpLists.php
│   ├── Mailchimp.php
│   ├── MailchimpReports.php
│   └── MailchimpTemplates.php
├── tests
│   ├── MailchimpAutomationsTest.php
│   ├── MailchimpCampaignsTest.php
│   ├── MailchimpEcommerceTest.php
│   ├── MailchimpListsTest.php
│   ├── MailchimpReportsTest.php
│   ├── MailchimpTemplatesTest.php
│   ├── MailchimpTest.php
│   └── src
└── vendor
├── autoload.php
├── bin
├── composer
├── doctrine
├── guzzlehttp
├── phpdocumentor
├── phpspec
├── phpunit
├── psr
├── sebastian
├── symfony
└── webmozart

Again and again, I'm receiving the error "The MailChimp PHP library is missing the required GuzzleHttp library. Please check the installation notes in README.txt."

Greg Boggs’s picture

From your ascii art, it appears that the contents of your vendor folder have somehow become located next to the vendor folder.

What you want is to upload the precompiled library as is with Guzzlehttp inside vendor. If you get the guzzle error on your shared hosting then it most likely means something went wrong with copying the files to the server.

dpico’s picture

Thanks for your answer, Greg! I'm sorry, I didn't realise the ascii tree was not copied correctly for some reason. I think the directory structure is correct:

.
├── composer.json
├── composer.lock
├── CONTRIBUTING.md
├── phpunit.xml
├── README.md
├── src
│   ├── MailchimpAPIException.php
│   ├── MailchimpAutomations.php
│   ├── MailchimpCampaigns.php
│   ├── MailchimpCURLClient.php
│   ├── MailchimpEcommerce.php
│   ├── MailchimpLists.php
│   ├── Mailchimp.php
│   ├── MailchimpReports.php
│   └── MailchimpTemplates.php
├── tests
│   ├── MailchimpAutomationsTest.php
│   ├── MailchimpCampaignsTest.php
│   ├── MailchimpEcommerceTest.php
│   ├── MailchimpListsTest.php
│   ├── MailchimpReportsTest.php
│   ├── MailchimpTemplatesTest.php
│   ├── MailchimpTest.php
│   └── src
└── vendor
- ├── autoload.php
- ├── bin
- ├── composer
- ├── doctrine
- ├── guzzlehttp
- ├── phpdocumentor
- ├── phpspec
- ├── phpunit
- ├── psr
- ├── sebastian
- ├── symfony
- └── webmozart

Greg Boggs’s picture

And are the guzzle files under the guzzlehttp folder? Does the site work locally for you on your computer?

dpico’s picture

It seems so.

vendor/guzzlehttp/
├── guzzle
│   ├── build
│   ├── CHANGELOG.md
│   ├── composer.json
│   ├── docs
│   ├── LICENSE
│   ├── README.md
│   ├── src
│   ├── tests
│   └── UPGRADING.md
├── promises
│   ├── CHANGELOG.md
│   ├── composer.json
│   ├── LICENSE
│   ├── Makefile
│   ├── README.md
│   └── src
└── psr7
. ├── CHANGELOG.md
. ├── composer.json
. ├── LICENSE
. ├── Makefile
. ├── phpunit.xml.dist
. ├── README.md
. ├── src
. └── tests

I'm testing the site on a shared hosting environment. I haven't tried to install it locally on my computer. Should I?

Greg Boggs’s picture

It looks like you have everything you need for the module to work. So, the next most likely problem would be your shared host. Maybe they are running an old expired PHP version?

dpico’s picture

Drupal reports that it's being run on PHP 5.6.30. Is that a good version?

Greg Boggs’s picture

Yup! I'm out of ideas. :\

therobyouknow’s picture

Sorry to hear about your ongoing issue dpico and thank you for providing further information. Thanks also to Greg Boggs for his input.

I would suggest your options going forward might be:
- definitely confirm whether or not your site works on your local setup, i.e. whether you see the error or not there. I know you said "It seems so" in #53 - from that I'm not sure if that's a definite yes or no.
- try writing a very simple bit of PHP code that includes/requires another bit of PHP code in the same way that MailChimp does for Guzzle. Try to reproduce the same original issue with this simpler code on your shared server. Being more simple may enable you to experiment more quickly with less code to overwhelm, that's what I would try. Perhaps use analysis tools for coding standards to see if there is an issue with the dependency approach.
- consider your hosting options: Is it provided by your employer - can they give you enhanced access to the server to be able to do further diagnostics or analysis. Or are you paying for your shared hosting - did you know you can get reasonably priced full ubuntu machines for relatively low cost - consider: linode, digitalocean, google or amazon (I don't work for any of these or have any financial interest in them). Perhaps a fully controllable environment may be a more suitable solution for you.

dpico’s picture

Thanks Greg Boggs and thereobyouknow for your answers! I'll try to follow your suggestions and will keep reporting about this.