网页 综合 更新时间 2026-11-13 17:31:55

Laravel Octane | Laravel 13.x - The clean stack for Artisans and agents

自动蜘蛛 laravel.com 正文约 5999 字
Laravel Octane | Laravel 13.x - The clean stack for Artisans and agents
Laravel Octane supercharges your application's performance by serving your application using high-powered application servers, including FrankenPHP, Open Swoole, Swoole, and RoadRunner. Octane boots your application once, keeps it in memory, and then feeds it requests at supersonic speeds.
Octane may be installed via the Composer package manager:
After installing Octane, you may execute the octane:install Artisan command, which will install Octane's configuration file into your application:
FrankenPHP is a PHP application server, written in Go, that supports modern web features like early hints, Brotli, and Zstandard compression. When you install Octane and choose FrankenPHP as your server, Octane will automatically download and install the FrankenPHP binary for you.
The FrankenPHP static binary includes its own copy of PHP, so updating your system's PHP installation will not update the PHP version used by Octane. You may check the bundled PHP version using the ./frankenphp version command. To apply PHP security updates, delete the frankenphp binary from your project's root directory and run the php artisan octane:install --server=frankenphp Artisan command to download the latest release, then restart Octane. If FrankenPHP is installed system-wide, update it using the method you used to install it.
If you plan to develop your application using Laravel Sail, you should run the following commands to install Octane and FrankenPHP:
Next, you should use the octane:install Artisan command to install the FrankenPHP binary:
Finally, add a SUPERVISOR_PHP_COMMAND environment variable to the laravel.test service definition in your application's docker-compose.yml file. This environment variable will contain the command that Sail will use to serve your application using Octane instead of the PHP development server:
To enable HTTPS, HTTP/2, and HTTP/3, apply these modifications instead:
Typically, you should access your FrankenPHP Sail application via https://localhost, as using https://127.0.0.1 requires additional configuration and is discouraged.
Using FrankenPHP's official Docker images can offer improved performance and the use of additional extensions not included with static installations of FrankenPHP. In addition, the official Docker images provide support for running FrankenPHP on platforms it doesn't natively support, such as Windows. FrankenPHP's official Docker images are suitable for both local development and production usage.
You may use the following Dockerfile as a starting point for containerizing your FrankenPHP powered Laravel application:
Then, during development, you may utilize the following Docker Compose file to run your application:
If the --log-level option is explicitly passed to the php artisan octane:start command, Octane will use FrankenPHP's native logger and, unless configured differently, will produce structured JSON logs.
You may consult the official FrankenPHP documentation for more information on running FrankenPHP with Docker.
When using FrankenPHP, you may specify a custom Caddyfile using the --caddyfile option when starting Octane:
This allows you to customize FrankenPHP's configuration beyond the default settings, such as adding custom middleware, configuring advanced routing, or setting up custom directives. You may consult the official Caddy documentation for more information on Caddyfile syntax and configuration options.
RoadRunner is powered by the RoadRunner binary, which is built using Go. The first time you start a RoadRunner based Octane server, Octane will offer to download and install the RoadRunner binary for you.
If you plan to develop your application using Laravel Sail, you should run the following commands to install Octane and RoadRunner:
Next, you should start a Sail shell and use the rr executable to retrieve the latest Linux based build of the RoadRunner binary:
Then, add a SUPERVISOR_PHP_COMMAND environment variable to the laravel.test service definition in your application's docker-compose.yml file. This environment variable will contain the command that Sail will use to serve your application using Octane instead of the PHP development server:
Finally, ensure the rr binary is executable and build your Sail images:
If you plan to use the Swoole application server to serve your Laravel Octane application, you must install the Swoole PHP extension. Typically, this can be done via PECL:
If you want to use the Open Swoole application server to serve your Laravel Octane application, you must install the Open Swoole PHP extension. Typically, this can be done via PECL:
Using Laravel Octane with Open Swoole grants the same functionality provided by Swoole, such as concurrent tasks, ticks, and intervals.
Before serving an Octane application via Sail, ensure you have the latest version of Laravel Sail and execute ./vendor/bin/sail build --no-cache within your application's root directory.
Alternatively, you may develop your Swoole based Octane application using Laravel Sail, the official Docker based development environment for Laravel. Laravel Sail includes the Swoole extension by default. However, you will still need to adjust the docker-compose.yml file used by Sail.
To get started, add a SUPERVISOR_PHP_COMMAND environment variable to the laravel.test service definition in your application's docker-compose.yml file. This environment variable will contain the command that Sail will use to serve your application using Octane instead of the PHP development server:
Finally, build your Sail images:
Swoole supports a few additional configuration options that you may add to your octane configuration file if necessary. Because they rarely need to be modified, these options are not included in the default configuration file:
The Octane server can be started via the octane:start Artisan command. By default, this command will utilize the server specified by the server configuration option of your application's octane configuration file:
By default, Octane
访问原文 返回搜索 https://laravel.com/framework/docs/octane
本页为82搜索生成的网页快照,内容来自站内索引;演示数据的原文链接仅作示例。