-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Improving the server:run command #10827
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
Comments
Good idea, but instead of replacing, it could be added to existing command. |
👍 |
Does PHP support running a background process or will it kill the child process when the PHP process ends ? |
@stof I have no idea, but I trust the ability of @romainneutron, the wizard of the Console and Process components. |
impressed and curious to see how it could work on windows |
here is an example to start a daemon (background process). <?php
$pid = pcntl_fork();
if($pid < 0){
//something wrong
exit;
}
if($pid > 0){
//this is parent process.
echo "child process start with pid $pid";
exit;
}
posix_setsid(); // detach f
8000
rom current terminal
//daemon process start here |
👍 for me too! |
If it's possible for all OS's: a big 👍 |
👍 I like the idea. |
i usually run the app with One problem I do see, though: currently, it's possible to run the server twice for 1 application (with different ports). If the servers are started in the background, how will server:status and server:stop known which one to act upon? Or should running multiple servers for one app be blocked altogether? How should that be enforced? a lock file? |
Maybe it's me but I don't see any value from this, Adding and maintaining PHP classes just for a simple command: |
@Burgov you could just enumerate all different servers or tell the command on which port you want to run - and kill it with this exact port number. I like the idea 👍 |
👍 |
As previously said, please keep And as to how to do it, wouldn't just running To be clear I mean |
@liuggio @mnapoli In other words, if you just execute one single application at a time, these proposed commands aren't necessary. If you run 3 or more applications, these command would definitely make your life as a developer easier. |
@javiereguiluz I just said "please also keep server:run", I don't see a problem with adding those new commands. |
That doesn't detach the process from the current terminals/shell process. This means as soon as you leave the shell, it will also kill the child processes. See |
@kingcrunch yes nohup, you get what I meant anyway. |
Hello, with the upcoming LockFile command helper (it solves @javiereguiluz issue) and the use of Running the command |
👍 |
I'd be interested in seeing the entire Let's talk about issues every time:
This is a nightmare for the average dev, and we're at the point where the |
@buzzedword this is not exclusive to improving the FrameworkBundle commands. Providing a VM environment configured to run Symfony is out of the scope of FrameworkBundle though. It is best kept as a separate project (and I think some people already provide such setups in forks of symfony-standard or their own repos). you might even use Homestead I think, if you adapt the |
…l PHP's built-in web server (xabbuh) This PR was merged into the 2.6-dev branch. Discussion ---------- [FrameworkBundle] Additional helper commands to control PHP's built-in web server | Q | A | ------------- | --- | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #10827 | License | MIT | Doc PR | symfony/symfony-docs#4005 Basically, both the ``server:status`` and ``server:stop`` wouldn't be really reliable if you had stopped the web server by, for example, killing the process. But honestly I don't know how to platform-independently determine if a process is still running given its PID. Maybe such a way could be a good improvement for the Process component. Commits ------- b601454 new helper commands for PHP's built-in server
👍 awesome addition, thanks @fabpot ! |
The problem
The
server:run
command is both good and bad for beginners. It's good because it makes unnecessary to mess with Apache configuration. But it's bad because executing it blocks the console:As
server:run
doesn't return the user to the regular shell, he/she needs to open another console or he/she needs to launch the command in the background (server run &
).The proposed solution
I'd like to replace the current
server:run
command with three new commands modeled after the traditional web servers:server:start
, it launches the built-in web server in the background and return the user to the regular shell.server:status
, it checks if the server is running and tells you the URL and the port.server:stop
, it stops the server launched with theserver:start
command.As an added bonus, when launching the built-in server, the command could also check the availability of the
8000
port to choose the next available port number when the8000
port is already used.The text was updated successfully, but these errors were encountered: