google/cloud-tools
Dev utilities for Google Cloud in PHP. Includes flex_exec to run commands inside the same Docker image as an App Engine Flexible deployment, with optional Cloud SQL connectivity via Cloud Build. Also provides Google\Cloud\TestUtils helpers and fixtures.
Install the package as a require-dev dependency:
composer require google/cloud-tools --dev
The most immediate value is the flex_exec utility for running Laravel CLI commands in the exact App Engine Flex production environment. To start:
./vendor/bin/flex_exec run -- php artisan migrate
Before first use, ensure:
gcloud CLI is authenticated (gcloud auth login / gcloud auth application-default login)Cloud SQL Client role if accessing Cloud SQLFor testing, begin with Google\Cloud\TestUtils\TestTrait (validates env vars/credentials) and ExecuteCommandTrait (runs commands reliably in tests).
flex_exec for production-accurate CLI workflowsvendor/bin/flex_exec run -- php artisan migrate:fresh --seed
vendor/bin/flex_exec run -- php artisan queue:work --queue=high
gmagick extension, differing timezone configs, or Cloud SQL socket paths).TestTrait::checkEnv() to guard tests against missing GOOGLE_PROJECT_ID or GOOGLE_APPLICATION_CREDENTIALS.ExponentialBackoffTrait’s useResourceExhaustedBackoff().ExecuteCommandTrait::runCommand('curl ...') to validate endpoints end-to-end..github/workflows/ci-cs-fixer.yml) to enforce code style consistency across Laravel codebases.FileUtil::copy() and FileUtil::move() in test helpers to manage temporary fixture files for storage/service tests.Override default deployment behavior via env vars:
GOOGLE_VERSION_ID=my-test-version vendor/bin/flex_exec run -- php artisan db:seed
Useful for testing against canary/staging versions before full rollout.
flex_exec fails if GOOGLE_APPLICATION_CREDENTIALS is missing. Always set it in CI (-e GOOGLE_APPLICATION_CREDENTIALS=/creds.json)..env is not loaded inside flex_exec. Explicitly set APP_ENV=production or pass --env=production to avoid config caching:
vendor/bin/flex_exec run -- bash -c "APP_ENV=production php artisan config:clear && php artisan migrate"
Your config/database.php must use DB_SOCKET (not DB_HOST) for Flex:
'connections' => [
'mysql' => [
'driver' => 'mysql',
'host' => env('DB_SOCKET', '127.0.0.1'), // Critical!
'database' => env('DB_DATABASE'),
...
],
],
migrate call uses ~30s; in CI, runs multiply quickly. Monitor in Cloud Billing > Reports.GOOGLE_SKIP_DEPLOYMENT=true skips all deployment steps (including beforeDeploy hooks) — useful for testing against existing prod deployments.GOOGLE_KEEP_DEPLOYMENT=true during local debugging to inspect the deployed app (otherwise it’s auto-cleared post-test).flex_exec uses a Flex image with matching PHP/Symfony versions. Verify via php -v and composer show symfony/* in the Flex container./workspace as CWD, not base_path(). Use __DIR__ or base_path() explicitly in test code.How can I help you explore Laravel packages today?