0
votes

So I followed the instructions on how to use composer to install google's api client.

When I try to open a file in my web browser that only has this code

<?php

require_once 'vendor/autoload.php';

I get these errors from my hosting provider

[03-Aug-2017 23:46:22 UTC] PHP Warning: require(/home/michmarket/public_html/vendor/composer/../guzzlehttp/psr7/src/functions_include.php): failed to open stream: No such file or directory in /home/michmarket/public_html/vendor/composer/autoload_real.php on line 66 [03-Aug-2017 23:46:22 UTC] PHP Fatal error: require(): Failed opening required '/home/michmarket/public_html/vendor/composer/../guzzlehttp/psr7/src/functions_include.php' (include_path='.:/opt/alt/php56/usr/share/pear:/opt/alt/php56/usr/share/php') in /home/michmarket/public_html/vendor/composer/autoload_real.php on line 66

I tried to make sure that all of the files API files up to date by running this in my command prompt.

$ composer require google/apiclient:^2.0

When I do, my command prompt says that all my files are up to date. Any thoughts on why I am still getting errors?

1
Try removing the vendor directory and doing a fresh composer install. Pay attention to any warning/error messages shown during that process.ceejayoz
I just deleted my entire vendor folder and ran composer install in my directory, but I'm getting the exact same errors.ChaseRun
Does the vendor/guzzlehttp/psr7/src/functions_include.php file exist?ceejayoz
It exists when I search the directory on my computerChaseRun
Does it exist on the server, where you need it to? Did you do composer install on the server?ceejayoz

1 Answers

1
votes

If you can't run

$ composer install

on your web server, then you need to transfer your vendor directory to your web server after running the command on your deployment server.

If your deployment server is your local machine, try to make it match the web server in terms of platform requirements as close as possible (PHP versions, you could be running newer versions locally than on the web server), or refer to https://getcomposer.org/doc/06-config.md#platform:

Lets you fake platform packages (PHP and extensions) so that you can emulate a production env or define your target platform in the config. Example: {"php": "5.4", "ext-something": "4.0"}.

Note You might want to optimize the autoloading as well, take a look at https://getcomposer.org/doc/articles/autoloader-optimization.md#autoloader-optimization.