- Can I use happyr/google-api-bundle in a Laravel application?
- No. happyr/google-api-bundle is a Symfony bundle that registers a Bundle class and a dependency-injection extension, and Laravel has no bundle registration mechanism. You cannot install it and wire it up the way its author intended. The useful part, a configured Google_Client, is roughly 40 lines of a Laravel service provider, so bypassing the package is simpler and safer.
- How do I install happyr/google-api-bundle?
- You would install it with Composer and then register the bundle in a Symfony kernel, which is not something Laravel supports. Its service definitions depend on Symfony Config and DependencyInjection components, so manually instantiating them outside the Symfony container is fragile. For Laravel, install google/apiclient instead and configure it in a service provider.
- Is happyr/google-api-bundle still maintained?
- No. The last release was September 2018, roughly seven years ago, and it targets the Symfony 2, 3, and 4 era with PHP 7.x constraints. It has zero dependents, so there is no downstream pressure to fix breakage and no community patch path. Unmaintained wrappers around OAuth and credential code are also a security concern.
- What is the best Laravel alternative to happyr/google-api-bundle?
- Use google/apiclient v2.x directly and wrap it yourself. Bind a singleton Google\Client in a service provider, read credentials from config and environment variables, and add thin typed clients per Google service so feature code never touches raw Google_Service classes. That gives you modern PHP and Guzzle 7 support plus an actively maintained auth flow.
- How do I configure Google API credentials and scopes in Laravel?
- Put the client ID, client secret, scopes, service account JSON path, and developer key in config/google.php, sourced from environment variables so secrets are never committed. Resolve them through Laravel's config cache, then build the Google\Client singleton from that array in a service provider. The bundle's own configuration array maps one-to-one, which makes porting mechanical.
- Does happyr/google-api-bundle support Laravel 11, PHP 8.2, and Guzzle 7?
- Almost certainly not. The bundle pins Symfony 2/3/4-era dependencies and PHP 7.x constraints, and its transitive Guzzle and PSR constraints will likely conflict with modern Laravel, which expects guzzlehttp/guzzle ^7 and current psr packages. Expect Composer resolution failure or forced downgrades. Verify the PHP floor, Guzzle major version, and psr constraints before committing to anything.
- How do I register a Google_Client singleton in a Laravel service provider?
- In a service provider's register method, bind Google\Client as a singleton and build it from config, then call setAuthConfig, add scopes, and set the access token or subject as needed. Resolve it through the container wherever you need it. Keep Google_Service construction in small typed client classes rather than injecting the raw client everywhere.
- How do I handle OAuth token storage and refresh in Laravel?
- The Google API PHP client does not manage token storage for you, so persist access and refresh tokens in the database or cache keyed to your user or tenant. Refresh explicitly when the token is expired, and handle revoked or invalid grants by sending the user through the consent flow again. For server-to-server work, use service accounts or domain-wide delegation instead of interactive OAuth.
- How do I test a Google API integration in Laravel without hitting real APIs?
- Mock at the boundary rather than calling Google. Bind a fake or mock Google\Client in the container, or inject a fake HTTP client into the SDK so requests are recorded and stubbed. Assert on the outgoing request payloads and on your own typed client behavior, and keep a small number of optional integration tests for the real auth flow.
- How do I migrate from the Symfony GoogleApiBundle to a Laravel integration?
- Extract the bundle's configuration array, including client ID, secret, scopes, service account JSON path, and developer key, and remap it one-to-one into config/google.php. The bundle's only real behavior is building a Google_Client from that config, so the mapping is mechanical. Code that type-hints Google_Client or Google_Service classes transfers unchanged, which keeps the port low risk.