Skip to content

Conversation

7amoood
Copy link
Contributor

@7amoood 7amoood commented Oct 4, 2025

This PR enhances the Octane bootstrap process and server start commands with better environment handling and support for custom vendor paths.

Changes

  • Added vendor_path option in config/octane.php:
    • Defaults to base_path('vendor').
    • Can be overridden via the OCTANE_VENDOR_PATH environment variable.
  • Updated bootstrap to use getenv() instead of $_ENV, ensuring environment variables are always available without requiring changes to php.ini (variables_order).
  • Updated Swoole, RoadRunner, and FrankenPHP server processes to pass COMPOSER_VENDOR_DIR from config('octane.vendor_path') to the environment.

Why

  • $_ENV may return null if PHP is not configured with E in variables_order. Using getenv() avoids this issue.
  • Allowing a configurable vendor path makes Octane more flexible in setups where the vendor directory is not in the default location.
  • Ensures all supported servers consistently receive the correct COMPOSER_VENDOR_DIR.

Impact

  • Backwards-compatible: defaults to the existing vendor path.
  • No breaking changes for current Octane users.
  • Provides greater flexibility and reliability across environments.

… variables are accessible

This PR updates the `bootstrap` file to use `getenv()` instead of `$_ENV` when retrieving environment variables.

In some PHP configurations, `$_ENV` returns `null` unless the `variables_order` setting in `php.ini` includes the `E` flag. This can cause Octane to fail when resolving the application base path or vendor directory.

By switching to `getenv()`, Octane can reliably fetch environment variables without requiring users to modify their PHP configuration.

### Changes
- Replaced `$_ENV['APP_RUNNING_IN_CONSOLE']` with `getenv('APP_RUNNING_IN_CONSOLE')`.
- Ensured `COMPOSER_VENDOR_DIR` and other variables are resolved consistently.

### Why
When extending the Swoole server start process and attempting to change the vendor file path, `$_ENV` returned `null` unless `variables_order` was explicitly configured. This fix ensures smoother setup for developers across different environments.

### Impact
- No breaking changes.
- Improves reliability of environment variable handling in Swoole/Octane bootstrap.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants