You need to return your Google API key as a string
see: https://developers.google.com/maps/documentation/directions/get-api-key
see: https://developers.google.com/maps/documentation/directions/intro#Introduction
( ! ) Warning: Undefined array key 0 in /var/www/html/php7cookbook/source/chapter07/chap_07_simple_rest_client_google_maps_streams.php on line 41
( ! ) Warning: Attempt to read property "legs" on null in /var/www/html/php7cookbook/source/chapter07/chap_07_simple_rest_client_google_maps_template.php on line 23
( ! ) Warning: foreach() argument must be of type array|object, null given in /var/www/html/php7cookbook/source/chapter07/chap_07_simple_rest_client_google_maps_template.php on line 23
( ! ) Warning: Attempt to read property "bounds" on null in /var/www/html/php7cookbook/source/chapter07/chap_07_simple_rest_client_google_maps_template.php on line 63
( ! ) Warning: Attempt to read property "copyrights" on null in /var/www/html/php7cookbook/source/chapter07/chap_07_simple_rest_client_google_maps_template.php on line 63