|
| 1 | +.. index:: Vagrant, Homestead |
| 2 | + |
| 3 | +Using Symfony with Homestead/Vagrant |
| 4 | +==================================== |
| 5 | + |
| 6 | +In order to develop a Symfony application, you might want to use a virtual |
| 7 | +development environment instead of the built-in server or WAMP/LAMP. Homestead_ |
| 8 | +is an easy-to-use Vagrant_ box to get a virtual environment up and running |
| 9 | +quickly. |
| 10 | + |
| 11 | +.. tip:: |
| 12 | + |
| 13 | + Due to the amount of filesystem operations in Symfony (e.g. updating cache |
| 14 | + files and writing to log files), Symfony can slow dow signifcantly. To |
| 15 | + improve the speed, consider :ref:`overriding the cache and log directories <override-cache-dir>` |
| 16 | + to a location outside the NFS share (for instance, by using |
| 17 | + :phpfunction:`sys_get_temp_dir`). |
| 18 | + |
| 19 | +Install Vagrant and Homestead |
| 20 | +----------------------------- |
| 21 | + |
| 22 | +Before you can use Homestead, you need to install and configure Vagrant and |
| 23 | +Homestead as explained in `the Homestead documentation`_. |
| 24 | + |
| 25 | +Setting Up a Symfony Application |
| 26 | +-------------------------------- |
| 27 | + |
| 28 | +Imagine you've installed your Symfony application in |
| 29 | +``~/projects/symfony_demo`` on your local system. You first need Homestead to |
| 30 | +sync your files in this project. Execute ``homestead edit`` to edit the |
| 31 | +Homestead configuration and configure the ``~/projects`` directory: |
| 32 | + |
| 33 | +.. code-block:: yaml |
| 34 | +
|
| 35 | + # ... |
| 36 | + folders: |
| 37 | + - map: ~/projects |
| 38 | + to: /home/vagrant/projects |
| 39 | +
|
| 40 | +The projects directory is now accessible at ``/home/vagrant/projects`` in the |
| 41 | +Homestead environment. |
| 42 | + |
| 43 | +After you've done this, configure the Symfony application in the Homestead |
| 44 | +configuration: |
| 45 | + |
| 46 | +.. code-block:: yaml |
| 47 | +
|
| 48 | + # ... |
| 49 | + sites: |
| 50 | + - map: symfony-demo.dev |
| 51 | + to: /home/vagrant/projects/symfony_demo/web |
| 52 | + type: symfony |
| 53 | +
|
| 54 | +The ``type`` option tells Homestead to use the Symfony nginx configuration. |
| 55 | + |
| 56 | +At last, edit the hosts file on your local machine to map ``symfony-demo.dev`` |
| 57 | +to ``192.168.10.10`` (which is the IP used by Homestead):: |
| 58 | + |
| 59 | + # /etc/hosts (unix) or C:\Windows\System32\drivers\etc\hosts (Windows) |
| 60 | + 192.168.10.10 symfony-demo.dev |
| 61 | + |
| 62 | +Now, navigate to ``http://symfony-demo.dev`` in your web browser and enjoy |
| 63 | +developing your Symfony application! |
| 64 | + |
| 65 | +.. seealso:: |
| 66 | + |
| 67 | + To learn more features of Homestead, including Blackfire Profiler |
| 68 | + integration, automatic creation of MySQL databases and more, read the |
| 69 | + `Daily Usage`_ section of the Homestead documentation. |
| 70 | + |
| 71 | +.. _Homestead: http://laravel.com/docs/homestead |
| 72 | +.. _Vagrant: https://www.vagrantup.com/ |
| 73 | +.. _the Homestead documentation: http://laravel.com/docs/homestead#installation-and-setup |
| 74 | +.. _Daily Usage: http://laravel.com/docs/5.1/homestead#daily-usage |
0 commit comments