Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork5.3k
[Cookbook] add cookbook article for the server:run command#4000
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| .. index:: | ||
| single: Web Server; Built-in Web Server | ||
| How to Use PHP's built-in Web Server | ||
| ==================================== | ||
| Since PHP 5.4 the CLI SAPI comes with a `built-in web server`_. It can be used | ||
| to run your PHP applications locally during development, for testing or for | ||
| application demonstrations. This way, you don't have to bother configuring | ||
| a full-featured web server such as | ||
| :doc:`Apache or Nginx </cookbook/configuration/web_server_configuration>`. | ||
| .. caution:: | ||
| The built-in web server is meant to be run in a controlled environment. | ||
| It is not designed to be used on public networks. | ||
| Starting the Web Server | ||
| ----------------------- | ||
| Running a Symfony application using PHP's built-in web server is as easy as | ||
| executing the ``server:run`` command: | ||
| .. code-block:: bash | ||
| $ php app/console server:run | ||
| This starts a server at ``localhost:8000`` that executes your Symfony application. | ||
| The command will wait and will respond to incoming HTTP requests until you | ||
| terminate it (this is usually done by pressing Ctrl and C). | ||
| By default, the web server listens on port 8000 on the loopback device. You | ||
| can change the socket passing an ip address and a port as a command-line argument: | ||
Member 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. How about this (for the same reason as above): | ||
| .. code-block:: bash | ||
| $ php app/console server:run 192.168.0.1:8080 | ||
Member 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. What about a really small section about VM's. Something like, which just comes from a few times of experience (so, I'll want someone else to give me a 👍 on this): MemberAuthor 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 like the idea of such an addition. What do you think about a sidebar for this? However, listening on 127.0.0.1 wouldn't work since it's the loopback device. I guess usually the internal interface is something like 192.168.0.1, 10.0.0.1 or similar. Member 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 like a sidebar. We should have someone try this - I don't have a VM handy (and my laptop's meager HD is too small to run one), but Ithink I remember MemberAuthor 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'm pretty sure that this doesn't work. But I agree that we should find someone to verify this. Member 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. Ah, I just had a chance to try this again. It's MemberAuthor 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. Yeah, Member 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 agree - use
| ||
| Command Options | ||
| --------------- | ||
| The built-in web server expects a "router" script (read about the "router" | ||
| script on `php.net`_) as an argument. Symfony already passes such a router | ||
| script when the command is executed in the ``prod`` or in the ``dev`` environment. | ||
| Use the ``--router`` option in any other environment or to use another router | ||
| script: | ||
| .. code-block:: bash | ||
| $ php app/console server:run --env=test --router=app/config/router_test.php | ||
| If your application's document root differs from the standard directory layout, | ||
| you have to pass the correct location using the ``--docroot`` option: | ||
| .. code-block:: bash | ||
| $ php app/console server:run --docroot=public_html | ||
| .. _`built-in web server`: http://www.php.net/manual/en/features.commandline.webserver.php | ||
| .. _`php.net`: http://php.net/manual/en/features.commandline.webserver.php#example-401 | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| Web Server | ||
| ========== | ||
| .. toctree:: | ||
| :maxdepth: 2 | ||
| built_in |