Reputation: 331
Is there a way to pass a custom php.ini to artisan serve
?
I've tried
php -c path/to/my/custom/php.ini artisan serve
This does not seem to affect the web server though?
I know where my .ini files are, and I know how to edit them. I just can't seem to make artisan serve
use a custom .ini.
I also looked at:
php artisan serve --help
and it didn't seem to list any options for setting the .ini.
My reason is that I have a custom .ini file with XDebug enabled. I want to be able to use it when debugging my Laravel app, but I don't want it enabled in my default php.ini
UPDATE
I've looked in
vendor\laravel\framework\src\Illuminate\Foundation\Console\ServeCommand.php
for Laravel 5.6.25 at lines 49-57 and they have this:
/**
* Get the full server command.
*
* @return string
*/
protected function serverCommand()
{
return sprintf('%s -S %s:%s %s',
ProcessUtils::escapeArgument((new PhpExecutableFinder)->find(false)),
$this->host(),
$this->port(),
ProcessUtils::escapeArgument(base_path('server.php'))
);
}
So it looks like it is not possible to pass in a custom .ini unless the PhpExecutableFinder would include the -c argument for the .ini path?
UPDATE 2
I looked in the PhpExecutableFinder, and it looked as if you could set a PHP_BINARY environment variable to override, however this did not work. It would be possible to have another complete copy of PHP that was configured for testing, but I'd rather have one PHP and just pass in my custom .ini.
Upvotes: 5
Views: 9017
Reputation: 31
This worked for me:
/public
echo 'upload_max_filesize=256m' >> user.ini
php -S 127.0.0.1:8000 -c user.ini '/absolute/path/to/laravel/project/server.php'
I've looked into vendor\laravel\framework\src\Illuminate\Foundation\Console\ServeCommand.php
and it doesn't seem like Laravel itself is doing much more than this.
Checking with phpinfo()
my upload_max_filesize
shows 256m
Upvotes: 3
Reputation: 331
After looking into the Laravel framework code for Laravel 5.6.25, it appears the answer is No, this is not possible. See question for more details.
Upvotes: 2