Skip to content

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

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cookbook/map.rst.inc
Original file line number Diff line number Diff line change
Expand Up @@ -262,3 +262,4 @@

* :doc:`/cookbook/workflow/new_project_git`
* :doc:`/cookbook/workflow/new_project_svn`
* :doc:`/cookbook/workflow/homestead`
76 changes: 76 additions & 0 deletions cookbook/workflow/homestead.rst
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.
Copy link
Member

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.

Copy link
Member Author

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.

Copy link
Member

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.

Copy link
Member Author

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.


.. 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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I find sync hard to understand. Is Homestead syncing my files with other folder (are they being copied/moved?), is Homestead just checking for their existance, etc.

Copy link
Member Author

Choose a reason for hiding this comment

The 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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nginx

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the official spelling is "nginx": http://nginx.org/

Copy link
Member

Choose a reason for hiding this comment

The 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
1 change: 1 addition & 0 deletions cookbook/workflow/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ Workflow

new_project_git
new_project_svn
homestead