-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
Add "executable" option to server:run console command #23721
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
Changes from 1 commit
65dcd7a
9d4f729
2feb064
6c8aa40
c051b18
426b30a
b5ff2ba
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,8 @@ | |
|
||
namespace Symfony\Bundle\WebServerBundle; | ||
|
||
use Symfony\Component\Process\PhpExecutableFinder; | ||
|
||
/** | ||
* @author Fabien Potencier <fabien@symfony.com> | ||
*/ | ||
|
@@ -71,6 +73,13 @@ public function __construct($documentRoot, $env, $address = null, $router = null | |
throw new \InvalidArgumentException(sprintf('Port "%s" is not valid.', $this->port)); | ||
} | ||
|
||
if ($executable === null) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yoda-style as well |
||
$finder = new PhpExecutableFinder(); | ||
if (false === $executable = $finder->find()) { | ||
throw new \RuntimeException('Unable to find the PHP executable.'); | ||
} | ||
} | ||
|
||
$this->executable = $executable; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I welcome any suggestions on how to validate this. Using There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For now the command would just fail on the higher layer (in |
||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe we should "explode"
$executable
string. Depending on how the Process class is escaping the array, the first one will be the command name, see the example:If you pass a whole string as the command, it will be interpreted as its name. I did not test it, but I believe it will do the same in the end.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, yes... definitely. Thanks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not as simple as it seems. Consider following executable:
php -dmemory_limit=16M -dzend_extension="C:\Program Files\some_extension.dll"
. If I were to split this with spaces, it would break around theProgram Files
part. And parsing CLI arguments is way over the scope of this PR IMHO. I've googled for some ready-made solutions and everything is in the ballpark of hundred lines of code.I tried to repurpose
\Symfony\Component\Console\Input\StringInput
for this, but it feels very hacky and I needed to add new public method to it.See 50fda23
Tested with
php index.php s:r --docroot web\ --executable "php -dmemory_limit=512M -dinclude_path=\"c:\Program Files\""
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any suggestions welcome