Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[8.x] Inject the list of env vars that are passed on to the web server #38211

Closed
wants to merge 4 commits into from

Conversation

nhaynes
Copy link

@nhaynes nhaynes commented Aug 2, 2021

This is needed for when using a .env file but still need to provide environment variables to PHP or a PHP extension such as xdebug.

Currently, Laravel Sail won't work with xdebug if you provide the configuration thru the XDEBUG_MODE and XDEBUG_CONFIG environment variables because this command doesn't pass the variables onto the php web server. You are forced to provide the xdebug configuration in the php.ini file but that isn't convenient for being able to turn xdebug on/off and switch between modes.

I'm sure there are other use cases as well where being able to modify the list of variables that are passed on to the php webserver are useful, for instance this PR: #38208

nhaynes added 3 commits August 2, 2021 18:29
…to the built-in webserver are supplied to the command and can be overriden in a service provider.
@driesvints driesvints changed the title Updated ServeCommand to inject the list of env vars that are passed on to the web server [8.x] Inject the list of env vars that are passed on to the web server Aug 3, 2021
Comment on lines +47 to +52
public function __construct(array $passthruEnvVars = ['APP_ENV', 'LARAVEL_SAIL', 'PHP_CLI_SERVER_WORKERS'])
{
parent::__construct();

$this->passthruEnvVars = $passthruEnvVars;
}
Copy link
Contributor

@scott-davidjones scott-davidjones Aug 3, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this allow the user to remove the required APP_ENV and LARAVEL_SAIL environment variables? Originally those two were hard coded, presumably as they are required.

This will allow the user to effectively remove those variables by not passing them into the allowed array. Perhaps have a default array and array_merge the incoming $passthruEnvVars.

for example:

$this->passthruEnvVars = \array_merge(['APP_ENV', 'LARAVEL_SAIL', 'PHP_CLI_SERVER_WORKERS'], $passthruEnvVars);

@taylorotwell
Copy link
Member

Thanks for your pull request to Laravel!

Unfortunately, I'm going to delay merging this code for now. To preserve our ability to adequately maintain the framework, we need to be very careful regarding the amount of code we include.

If possible, please consider releasing your code as a package so that the community can still take advantage of your contributions!

If you feel absolutely certain that this code corrects a bug in the framework, please "@" mention me in a follow-up comment with further explanation so that GitHub will send me a notification of your response.

@taylorotwell
Copy link
Member

I would rather just explicitly list the XDEBUG variables.

@nhaynes
Copy link
Author

nhaynes commented Aug 3, 2021

@taylorotwell would you be more accepting of a PR that adds the XDEBUG_MODE and XDEBUG_CONFIG env vars to the list of hardcoded variables?

This is essentially the same issue that this PR was experiencing #38208 that was accepted yesterday. But instead of a PHP env var that controls multi-threading, these are env vars that control the xdebug extension.

Without some update to the current hardcoded version, we are forced to override theServeCommand::startProcess method in every project we wish to debug using sail so that these vars are passed on to PHP.

@nhaynes
Copy link
Author

nhaynes commented Aug 3, 2021

I would rather just explicitly list the XDEBUG variables.

@taylorotwell perfect. I'll make a new PR.

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.

4 participants