Skip to content

Commit 5448ad2

Browse files
committed
wip
1 parent 67f470d commit 5448ad2

File tree

8 files changed

+19
-72
lines changed

8 files changed

+19
-72
lines changed

README.md

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,19 +55,27 @@ This package requires Laravel 10 or 11.
5555

5656
# Installation
5757

58-
Require the package using Composer
58+
1 - Require the package using Composer
5959

6060
```bash
6161
composer require stackkit/laravel-google-cloud-scheduler
6262
```
6363

64-
Define the `STACKKIT_CLOUD_SCHEDULER_APP_URL` environment variable. This should be the URL defined in the `URL` field of your Cloud Scheduler job.
64+
2 - Define the `STACKKIT_CLOUD_SCHEDULER_APP_URL` environment variable. This should be the URL defined in the `URL` field of your Cloud Scheduler job.
6565

6666
```
6767
STACKKIT_CLOUD_SCHEDULER_APP_URL=https://yourdomainname.com/cloud-scheduler-job
6868
```
6969

70-
Optional, but highly recommended: server configuration
70+
3 - Ensure PHP executable is in open_basedir. This is required for the package to run Artisan commands.
71+
72+
How to find the executable:
73+
74+
```php
75+
php artisan tinker --execute="(new Symfony\\Component\\Process\\PhpExecutableFinder())->find()"
76+
```
77+
78+
4 - Optional, but highly recommended: server configuration
7179

7280
Since Artisan commands are now invoked via an HTTP request, you might encounter issues with timeouts. Here's how to adjust them:
7381

@@ -86,7 +94,7 @@ server {
8694
8795
```
8896

89-
Optional, but highly recommended: set application `RUNNING_IN_CONSOLE`
97+
5 - Optional, but highly recommended: set application `RUNNING_IN_CONSOLE`
9098

9199
Some 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:
92100

@@ -172,7 +180,7 @@ $app = new Illuminate\Foundation\Application(
172180
```
173181
</details>
174182

175-
Optional: whitelist route for maintenance mode
183+
6 - Optional: whitelist route for maintenance mode
176184

177185
If you want to allow jobs to keep running if the application is down (`php artisan down`), update the following:
178186

composer.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,7 @@
4848
],
4949
"clear": "@php vendor/bin/testbench package:purge-skeleton --ansi",
5050
"prepare": [
51-
"@php vendor/bin/testbench package:discover --ansi",
52-
"@php use-package-kernel.php"
51+
"@php vendor/bin/testbench package:discover --ansi"
5352
],
5453
"build": "@php vendor/bin/testbench workbench:build --ansi",
5554
"serve": [

src/TaskHandler.php

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,15 @@
88

99
class TaskHandler
1010
{
11-
private $command;
12-
1311
private $schedule;
1412

15-
private $container;
16-
1713
public function __construct(
18-
Command $command,
19-
Schedule $schedule,
20-
Container $container
14+
private Command $command,
15+
private Container $container
2116
) {
22-
$this->command = $command;
23-
$this->schedule = $schedule;
24-
$this->container = $container;
17+
Artisan::bootstrap();
18+
19+
$this->schedule = $container->make(Schedule::class);
2520
}
2621

2722
/**
@@ -46,8 +41,6 @@ public function handle()
4641

4742
private function runCommand($command)
4843
{
49-
Artisan::bootstrap();
50-
5144
if ($this->isScheduledCommand($command)) {
5245
$scheduledCommand = $this->getScheduledCommand($command);
5346

testbench.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
providers:
2-
- Workbench\App\Providers\WorkbenchServiceProvider
32
- Stackkit\LaravelGoogleCloudScheduler\CloudSchedulerServiceProvider
43

54
migrations:

tests/TaskHandlerTest.php

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,9 @@
33
namespace Tests;
44

55
use Illuminate\Console\Application as ConsoleApplication;
6-
use Illuminate\Console\Scheduling\Schedule;
7-
use Illuminate\Container\Container;
86
use Illuminate\Support\Facades\Event;
9-
use Mockery;
107
use PHPUnit\Framework\Attributes\Test;
11-
use Stackkit\LaravelGoogleCloudScheduler\CloudSchedulerException;
12-
use Stackkit\LaravelGoogleCloudScheduler\Command;
138
use Stackkit\LaravelGoogleCloudScheduler\OpenIdVerificator;
14-
use Stackkit\LaravelGoogleCloudScheduler\TaskHandler;
15-
use UnexpectedValueException;
16-
use Workbench\App\Events\TaskOutput;
179

1810
class TaskHandlerTest extends TestCase
1911
{

tests/TestCase.php

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,6 @@ class TestCase extends \Orchestra\Testbench\TestCase
88
{
99
use WithWorkbench;
1010

11-
/**
12-
* Get package providers. At a minimum this is the package being tested, but also
13-
* would include packages upon which our package depends, e.g. Cartalyst/Sentry
14-
* In a normal app environment these would be added to the 'providers' array in
15-
* the config/app.php file.
16-
*
17-
* @param \Illuminate\Foundation\Application $app
18-
* @return array
19-
*/
20-
protected function getPackageProviders($app)
21-
{
22-
return [
23-
\Stackkit\LaravelGoogleCloudScheduler\CloudSchedulerServiceProvider::class,
24-
];
25-
}
26-
2711
protected function defineEnvironment($app)
2812
{
2913
if (! defined('ARTISAN_BINARY')) {

use-package-kernel.php

Lines changed: 0 additions & 10 deletions
This file was deleted.

workbench/app/Providers/WorkbenchServiceProvider.php

Lines changed: 0 additions & 18 deletions
This file was deleted.

0 commit comments

Comments
 (0)