-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Added doc about Homestead's Symfony integration #5655
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 all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
.. index:: Vagrant, Homestead | ||
|
||
Using Symfony with Homestead/Vagrant | ||
==================================== | ||
|
||
In order to develop a Symfony application, you might want to use a virtual | ||
development environment instead of the built-in server or WAMP/LAMP. Homestead_ | ||
is an easy-to-use Vagrant_ box to get a virtual environment up and running | ||
quickly. | ||
|
||
.. tip:: | ||
|
||
Due to the amount of filesystem operations in Symfony (e.g. updating cache | ||
files and writing to log files), Symfony can slow down signifcantly. To | ||
improve the speed, consider :ref:`overriding the cache and log directories <override-cache-dir>` | ||
to a location outside the NFS share (for instance, by using | ||
:phpfunction:`sys_get_temp_dir`). You can read `this blog post`_ for more | ||
tips to speed up Symfony on Vagrant. | ||
|
||
Install Vagrant and Homestead | ||
----------------------------- | ||
|
||
Before you can use Homestead, you need to install and configure Vagrant and | ||
Homestead as explained in `the Homestead documentation`_. | ||
|
||
Setting Up a Symfony Application | ||
-------------------------------- | ||
|
||
Imagine you've installed your Symfony application in | ||
``~/projects/symfony_demo`` on your local system. You first need Homestead to | ||
sync your files in this project. Execute ``homestead edit`` to edit the | ||
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 find 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. Homestead is syncing the local directory with the directory you mapped it to in the Homestead environment, I'll expand the description a bit. |
||
Homestead configuration and configure the ``~/projects`` directory: | ||
|
||
.. code-block:: yaml | ||
|
||
# ... | ||
folders: | ||
- map: ~/projects | ||
to: /home/vagrant/projects | ||
|
||
The ``projects/`` directory on your PC is now accessible at | ||
``/home/vagrant/projects`` in the Homestead environment. | ||
|
||
After you've done this, configure the Symfony application in the Homestead | ||
configuration: | ||
|
||
.. code-block:: yaml | ||
|
||
# ... | ||
sites: | ||
- map: symfony-demo.dev | ||
to: /home/vagrant/projects/symfony_demo/web | ||
type: symfony | ||
|
||
The ``type`` option tells Homestead to use the Symfony nginx configuration. | ||
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. Nginx 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. the official spelling is "nginx": http://nginx.org/ 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. oh, looks like we need to update some places then |
||
|
||
At last, edit the hosts file on your local machine to map ``symfony-demo.dev`` | ||
to ``192.168.10.10`` (which is the IP used by Homestead):: | ||
|
||
# /etc/hosts (unix) or C:\Windows\System32\drivers\etc\hosts (Windows) | ||
192.168.10.10 symfony-demo.dev | ||
|
||
Now, navigate to ``http://symfony-demo.dev`` in your web browser and enjoy | ||
developing your Symfony application! | ||
|
||
.. seealso:: | ||
|
||
To learn more features of Homestead, including Blackfire Profiler | ||
integration, automatic creation of MySQL databases and more, read the | ||
`Daily Usage`_ section of the Homestead documentation. | ||
|
||
.. _Homestead: http://laravel.com/docs/homestead | ||
.. _Vagrant: https://www.vagrantup.com/ | ||
.. _the Homestead documentation: http://laravel.com/docs/homestead#installation-and-setup | ||
.. _Daily Usage: http://laravel.com/docs/5.1/homestead#daily-usage | ||
.. _this blog post: http://www.whitewashing.de/2013/08/19/speedup_symfony2_on_vagrant_boxes.html |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,3 +6,4 @@ Workflow | |
|
||
new_project_git | ||
new_project_svn | ||
homestead |
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.
Would it be appropriate to expand this introduction explaining the advantages and drawbacks of using Homestead with Symfony? For example, this method may run Symfony significantly slower than the native method ... or maybe not, etc.
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 definitely think it's a good idea to link to http://www.whitewashing.de/2013/08/19/speedup_symfony2_on_vagrant_boxes.html in a tip box.
I'll also add another paragraph after this with the advantages/disadvantages of using vagrant.
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'm worried about this because people usually brag about Vagrant advantages but forget its drawbacks. Besides being much much much slower than the native application, it causes lots of other minor issues/troubles/misunderstandings (like these Symfony issues related (somehow) to Vagrant).
I'm not saying that Vagrant is bad. But I'd like to state clear to readers that using Vagrant will make your Symfony run very slow and it may cause other (minor) troubles totally unrelated to Symfony.
And about linking to third-party resources, I think I was wrong, I apologize for that and I think we should start linking to trustworthy third-party resources, like Benjamin's blog.
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.
Many of the linked issues are related to someone saying "Hey, I tested this on a clean Vagrant box", which is exactly why Vagrant was created in the first place. I can't see many issues directly related to Vagrant bugs.
And following some guides from Benjamin's blog can speed up applications very nicely. In fact, on my Windows PC, applications run on Homestead are much faster and consume less CPU than those running on the built-in PHP webserver or Wamp.