Answer the question
In order to leave comments, you need to log in
Google Api Client for PHP and Composer library?
Hello!
There was a problem adding the Google Api Client for PHP library using Composer. I ask for your help!
Before that, I did not encounter Composer, and only today I installed it, following this instruction . Composer starts, tested with the command: $ composer
Next, I added the Google library: composer require google/apiclient:^[email protected]
The library was pulled up, here is the content of composer.json
{
"require": {
"google/apiclient": "^[email protected]"
}
}
─root
├─.composer(папка)
├─composer.lock
├─composer.json
└─vendor(папка)
├─autoload.php
├─composer(папка)
└─google(папка)
└─...
─var
├─www(папка)
└─html(папка)
└─index.php
require_once 'vendor/autoload.php';
$client = new Google_Client();
$client->setApplicationName("Client_Library_Examples");
$client->setDeveloperKey("YOUR_APP_KEY");
$service = new Google_Service_Books($client);
$optParams = array('filter' => 'free-ebooks');
$results = $service->volumes->listVolumes('Henry David Thoreau', $optParams);
foreach ($results as $item) {
echo $item['volumeInfo']['title'], "<br /> \n";
}
PHP Warning: require_once(vendor/autoload.php): failed to open stream: No such file or directory in
/var/www/html/index.php on line 3
PHP Fatal error: require_once(): Failed opening required 'vendor/autoload.php'
(include_path='.:/usr/share/php:/usr/share/pear') in /var/www/html/index.php on line 3
Answer the question
In order to leave comments, you need to log in
require_once 'vendor/autoload.php';
This would work if you had index.php in root.
try
require_once '../../../../root/vendor/autoload.php';
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question