{"id":33997481,"url":"https://github.com/stackkit/laravel-google-cloud-scheduler","last_synced_at":"2025-12-13T08:58:28.397Z","repository":{"id":39652133,"uuid":"273975954","full_name":"stackkit/laravel-google-cloud-scheduler","owner":"stackkit","description":"This package allows you to use Google Cloud Scheduler to schedule Laravel commands.","archived":false,"fork":false,"pushed_at":"2025-03-16T12:29:35.000Z","size":587,"stargazers_count":32,"open_issues_count":0,"forks_count":5,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-11-07T04:27:35.895Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/stackkit.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-06-21T20:07:49.000Z","updated_at":"2025-09-24T15:41:40.000Z","dependencies_parsed_at":"2024-03-29T23:21:54.491Z","dependency_job_id":"4ed6c745-5a06-4457-a061-2b2be2ba106f","html_url":"https://github.com/stackkit/laravel-google-cloud-scheduler","commit_stats":{"total_commits":55,"total_committers":2,"mean_commits":27.5,"dds":"0.018181818181818188","last_synced_commit":"900c656f09d0b0e37667312fe6ea266e93267ecc"},"previous_names":[],"tags_count":19,"template":false,"template_full_name":null,"purl":"pkg:github/stackkit/laravel-google-cloud-scheduler","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stackkit%2Flaravel-google-cloud-scheduler","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stackkit%2Flaravel-google-cloud-scheduler/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stackkit%2Flaravel-google-cloud-scheduler/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stackkit%2Flaravel-google-cloud-scheduler/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stackkit","download_url":"https://codeload.github.com/stackkit/laravel-google-cloud-scheduler/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stackkit%2Flaravel-google-cloud-scheduler/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":27702869,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-12-13T02:00:09.769Z","response_time":147,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-12-13T08:58:27.669Z","updated_at":"2025-12-13T08:58:28.391Z","avatar_url":"https://github.com/stackkit.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cimg src=\"/logo.png\" width=\"400\"\u003e\n\n[![Run tests](https://github.com/stackkit/laravel-google-cloud-scheduler/actions/workflows/run-tests.yml/badge.svg)](https://github.com/stackkit/laravel-google-cloud-scheduler/actions/workflows/run-tests.yml)\n\u003ca href=\"https://packagist.org/packages/stackkit/laravel-google-cloud-scheduler\"\u003e\u003cimg src=\"https://poser.pugx.org/stackkit/laravel-google-cloud-scheduler/v/stable.svg\" alt=\"Latest Stable Version\"\u003e\u003c/a\u003e\n\u003ca href=\"https://packagist.org/packages/stackkit/laravel-database-emails\"\u003e\u003cimg src=\"https://poser.pugx.org/stackkit/laravel-google-cloud-scheduler/downloads.svg\" alt=\"Downloads\"\u003e\u003c/a\u003e\n\n\u003csub\u003eCompanion packages: \u003ca href=\"https://github.com/stackkit/laravel-google-cloud-tasks-queue\"\u003eCloud Tasks\u003c/a\u003e, \u003ca href=\"https://github.com/marickvantuil/laravel-google-cloud-logging\"\u003eCloud Logging\u003c/a\u003e\u003c/sub\u003e\n\n# Introduction\n\nThis package allows you to use Google Cloud Scheduler to schedule Laravel commands.\n\n# How it works\n\nCloud Scheduler will make HTTP calls to your application. This package adds an endpoint to your application that accepts these HTTP calls with their payload (an Artisan command) and execute them.\n\nThere are two ways to schedule commands using this package:\n\n\u003cdetails\u003e\n\u003csummary\u003e1. Schedule the `schedule:run` command\u003c/summary\u003e\n\nThis is the easiest way to use this package. You can schedule the `schedule:run` command to run every minute.\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e2. Schedule commands separately\u003c/summary\u003e\n\nIf your application does not have commands that should run every minute, you may choose to schedule them individually.\n\nIf the command uses `withoutOverlapping`, `before`, `after`, `onSuccess`, `thenPing`, etc, this package will respect those settings, as long as the command is also scheduled in the console kernel.\n\nFor example, let's say we have to generate a report every day at 3:00 AM. We can schedule the `reports:generate` command to run at 3:00 AM using Cloud Scheduler. After the report is generated, OhDear should be pinged.\n\nFirstly, schedule the command in Cloud Tasks:\n\n\u003cimg src=\"/schedule-command-example.png\"\u003e\n\nThen, schedule the command in the console kernel:\n\n```php\npublic function schedule(Schedule $schedule)\n{\n    $schedule-\u003ecommand('report:generate')\n        -\u003ethenPing('https://ohdear.app/ping');\n}\n```\n\nThe package will pick up on the scheduled settings and ping OhDear after the command has run.\n\u003c/details\u003e\n\n# Requirements\n\nThis package requires Laravel 11 or 12.\n\n# Installation\n\n1 - Require the package using Composer\n\n```bash\ncomposer require stackkit/laravel-google-cloud-scheduler\n```\n\n2 - Define environment variables\n\n`CLOUD_SCHEDULER_APP_URL` - This should be the URL defined in the `URL` field of your Cloud Scheduler job.\n\n`CLOUD_SCHEDULER_SERVICE_ACCOUNT` - The e-mail address of the service account invocating the task.\n\nOptionally, you may publish the configuration file:\n\n```bash\nphp artisan vendor:publish --tag=cloud-scheduler-config\n```\n\n3 - Ensure PHP executable is in open_basedir. This is required for the package to run Artisan commands.\n\nHow to find the executable:\n\n```php\nphp artisan tinker --execute=\"(new Symfony\\\\Component\\\\Process\\\\PhpExecutableFinder())-\u003efind()\"\n```\n\n4 - Optional, but highly recommended: server configuration\n\nSince Artisan commands are now invoked via an HTTP request, you might encounter issues with timeouts. Here's how to adjust them:\n\n```nginx\nserver {\n    # other server configuration ...\n\n    location /cloud-scheduler-job {\n        proxy_connect_timeout 600s;\n        proxy_read_timeout 600s;\n        fastcgi_read_timeout 600s;\n    }\n\n    # other locations and server configuration ...\n}\n\n```\n\n5 - Optional, but highly recommended: set application `RUNNING_IN_CONSOLE`\n\nSome Laravel service providers only register their commands if the application is being accessed through the command line (Artisan). Because we are calling Laravel scheduler from a HTTP call, that means some commands may never register, such as the Laravel Scout command:\n\n```php\n/**\n * Bootstrap any application services.\n *\n * @return void\n */\npublic function boot()\n{\n    if ($this-\u003eapp-\u003erunningInConsole()) {\n        $this-\u003ecommands([\n            FlushCommand::class,\n            ImportCommand::class,\n            IndexCommand::class,\n            DeleteIndexCommand::class,\n        ]);\n\n        $this-\u003epublishes([\n            __DIR__.'/../config/scout.php' =\u003e $this-\u003eapp['path.config'].DIRECTORY_SEPARATOR.'scout.php',\n        ]);\n    }\n}\n```\n\nTo circumvent this, please add the following to `bootstrap/app.php`\n\n```php\n\u003c?php\n\nuse Illuminate\\Foundation\\Application;\nuse Illuminate\\Foundation\\Configuration\\Exceptions;\nuse Illuminate\\Foundation\\Configuration\\Middleware;\n\n+ if (($_SERVER['REQUEST_URI'] ?? '') === '/cloud-scheduler-job') {\n+     $_ENV['APP_RUNNING_IN_CONSOLE'] = true;\n+ }\n\nreturn Application::configure(basePath: dirname(__DIR__))\n    -\u003ewithRouting(\n        web: __DIR__.'/../routes/web.php',\n        commands: __DIR__.'/../routes/console.php',\n        health: '/up',\n    )\n    -\u003ewithMiddleware(function (Middleware $middleware) {\n        //\n    })\n    -\u003ewithExceptions(function (Exceptions $exceptions) {\n        //\n    })-\u003ecreate();\n\n```\n\n6 - Optional: whitelist route for maintenance mode\n\nIf you want to allow jobs to keep running if the application is down (`php artisan down`), update the following:\n\n```php\nreturn Application::configure(basePath: dirname(__DIR__))\n    -\u003ewithRouting(\n        web: __DIR__ . '/../routes/web.php',\n        commands: __DIR__ . '/../routes/console.php',\n        health: '/up',\n    )\n    -\u003ewithMiddleware(function (Middleware $middleware) {\n        $middleware-\u003epreventRequestsDuringMaintenance(\n            except: [\n                '/cloud-scheduler-job',\n            ],\n        );\n    })\n    -\u003ewithExceptions(function (Exceptions $exceptions) {\n        //\n    })-\u003ecreate();\n\n\n```\n\n# Cloud Scheduler Example\n\nHere is an example job that will run `php artisan schedule:run` every minute.\n\nThese are the most important settings:\n- Target must be `HTTP`\n- URL and AUD (audience) must be `https://yourdomainname.com/cloud-scheduler-job`\n- Auth header must be OIDC token!\n\n\u003cimg src=\"/example.png\"\u003e\n\n# Security\n\nThe job handler requires each request to have an OpenID token. Cloud Scheduler will generate an OpenID token and send it along with the job payload to the handler.\n\nThis package verifies that the token is digitally signed by Google and that it's meant for your application. Only Google Scheduler will be able to call your handler.\n\nMore information about OpenID Connect:\n\nhttps://developers.google.com/identity/protocols/oauth2/openid-connect\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstackkit%2Flaravel-google-cloud-scheduler","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstackkit%2Flaravel-google-cloud-scheduler","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstackkit%2Flaravel-google-cloud-scheduler/lists"}