Skip to content

Commit 5945842

Browse files
committed
Add details about the generated PHP file for Laravel Octane and clarify Caddyfile environment variable handling
1 parent fd558f7 commit 5945842

1 file changed

Lines changed: 16 additions & 1 deletion

File tree

  • docs/content/docs/3.framework-guides/1.laravel

‎docs/content/docs/3.framework-guides/1.laravel/octane.md‎

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,26 @@ First, install Octane in your Laravel application:
5353
docker compose run php composer require laravel/octane
5454
```
5555

56+
When that command runs, you should see a PHP file that Laravel creates in your `/public` directory. This is required for Laravel Octane to work.
57+
58+
```php [public/frankenphp-worker.php]
59+
<?php
60+
61+
// Set a default for the application base path and public path if they are missing...
62+
$_SERVER['APP_BASE_PATH'] = $_ENV['APP_BASE_PATH'] ?? $_SERVER['APP_BASE_PATH'] ?? __DIR__.'/..';
63+
$_SERVER['APP_PUBLIC_PATH'] = $_ENV['APP_PUBLIC_PATH'] ?? $_SERVER['APP_BASE_PATH'] ?? __DIR__;
64+
65+
require __DIR__.'/../vendor/laravel/octane/bin/frankenphp-worker.php';
66+
67+
```
68+
69+
It is safe to commit this file to your repository.
70+
5671
### Configure Worker Mode
5772
We now want to update the compose file to run Laravel Octane and use proper health checks.
5873

5974
::note
60-
Laravel Octane provides [its own Caddyfile](https://github.com/laravel/octane/blob/2.x/src/Commands/stubs/Caddyfile){target="_blank"}. This may cause some of the serversideup/php environment variables to not be respected. Be sure to review the official Octane Caddyfile for which variables are supported.
75+
Laravel Octane provides its own Caddyfile. This may cause some of the serversideup/php environment variables to not be respected (mainly any `CADDY_*` variables). Be sure to review the [official Laravel Octane Caddyfile](https://github.com/laravel/octane/blob/2.x/src/Commands/stubs/Caddyfile){target="_blank"} for which variables are supported.
6176
::
6277

6378
```yml [compose.yml]{8-13}

0 commit comments

Comments
 (0)