docker run -it --tty --rm --volume $PWD:/app --user $(id -u):$(id -g) composer require google/apiclient:^2.0
Then we just need to create the script to run, still in the same directory:-
include_once __DIR__ . '/vendor/autoload.php'; $GCSE_API_KEY = "nqwkoigrhe893utnih_gibberish_q2ihrgu9qjnr"; $GCSE_SEARCH_ENGINE_ID = "937592689593725455:msi299dkne4de"; $client = new Google_Client(); $client->setApplicationName("My_App"); $client->setDeveloperKey($GCSE_API_KEY); $service = new Google_Service_Customsearch($client); $optParams = array("cx"=>self::GCSE_SEARCH_ENGINE_ID); $results = $service->cse->listCse("lol cats", $optParams);
And we can run that script again using docker:-
docker run -it --rm --volume $PWD:/app -w /app php:5.5-cli php cse.php
Links:-
https://stackoverflow.com/questions/41592249/how-to-use-php-client-for-google-custom-search-engine
https://hub.docker.com/r/library/php/
https://hub.docker.com/r/library/composer/