Skip to content
  • About
    • What is Symfony?
    • Community
    • News
    • Contributing
    • Support
  • Documentation
    • Symfony Docs
    • Symfony Book
    • Screencasts
    • Symfony Bundles
    • Symfony Cloud
    • Training
  • Services
    • Platform.sh for Symfony Best platform to deploy Symfony apps
    • SymfonyInsight Automatic quality checks for your apps
    • Symfony Certification Prove your knowledge and boost your career
    • SensioLabs Professional services to help you with Symfony
    • Blackfire Profile and monitor performance of your apps
  • Other
  • Blog
  • Download
sponsored by
  1. Home
  2. Documentation
  3. Setup
  4. Using Symfony with Homestead/Vagrant

Using Symfony with Homestead/Vagrant

Edit this page

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 significantly. To improve the speed, consider overriding the cache and log directories to a location outside the NFS share (for instance, by using 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. Run homestead edit to edit the Homestead configuration and configure the ~/projects directory:

1
2
3
4
# ...
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:

1
2
3
4
5
# ...
sites:
    - map: symfony-demo.test
      to: /home/vagrant/projects/symfony_demo/public
      type: symfony4

The type option tells Homestead to use the Symfony nginx configuration. Homestead now supports a Symfony 2 and 3 web layout with app.php and app_dev.php when using type symfony2 and an index.php layout when using type symfony4.

At last, edit the hosts file on your local machine to map symfony-demo.test to 192.168.10.10 (which is the IP used by Homestead):

1
2
# /etc/hosts (unix) or C:\Windows\System32\drivers\etc\hosts (Windows)
192.168.10.10 symfony-demo.test

Now, navigate to http://symfony-demo.test in your web browser and enjoy developing your Symfony application!

See also

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.

This work, including the code samples, is licensed under a Creative Commons BY-SA 3.0 license.
TOC
    Version

    Symfony 7.1 is backed by

    Become certified from home

    Become certified from home

    Peruse our complete Symfony & PHP solutions catalog for your web development needs.

    Peruse our complete Symfony & PHP solutions catalog for your web development needs.

    Version:

    Table of Contents

    • Install Vagrant and Homestead
    • Setting Up a Symfony Application

    Symfony footer

    Avatar of Ivan Zugec, a Symfony contributor

    Thanks Ivan Zugec (@zugec) for being a Symfony contributor

    1 commit • 2 lines changed

    View all contributors that help us make Symfony

    Become a Symfony contributor

    Be an active part of the community and contribute ideas, code and bug fixes. Both experts and newcomers are welcome.

    Learn how to contribute

    Symfony™ is a trademark of Symfony SAS. All rights reserved.

    • What is Symfony?

      • What is Symfony?
      • Symfony at a Glance
      • Symfony Components
      • Symfony Releases
      • Security Policy
      • Logo & Screenshots
      • Trademark & Licenses
      • symfony1 Legacy
    • Learn Symfony

      • Symfony Docs
      • Symfony Book
      • Reference
      • Bundles
      • Best Practices
      • Training
      • eLearning Platform
      • Certification
    • Screencasts

      • Learn Symfony
      • Learn PHP
      • Learn JavaScript
      • Learn Drupal
      • Learn RESTful APIs
    • Community

      • Symfony Community
      • SymfonyConnect
      • Events & Meetups
      • Projects using Symfony
      • Contributors
      • Symfony Jobs
      • Backers
      • Code of Conduct
      • Downloads Stats
      • Support
    • Blog

      • All Blog Posts
      • A Week of Symfony
      • Case Studies
      • Cloud
      • Community
      • Conferences
      • Diversity
      • Living on the edge
      • Releases
      • Security Advisories
      • Symfony Insight
      • Twig
      • SensioLabs Blog
    • Services

      • SensioLabs services
      • Train developers
      • Manage your project quality
      • Improve your project performance
      • Host Symfony projects

      Powered by

    Follow Symfony