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 SensioLabs
  1. Home
  2. Documentation
  3. Best Practices
  4. Creating the Project
  • Documentation
  • Book
  • Reference
  • Bundles
  • Cloud

Table of Contents

  • Installing Symfony
  • Creating the Blog Application
  • Structuring the Application
    • Application Bundles

Creating the Project

Edit this page

Warning: You are browsing the documentation for Symfony 4.2, which is no longer maintained.

Read the updated version of this page for Symfony 6.3 (the current stable version).

Creating the Project

Installing Symfony

Best Practice

Use Composer and Symfony Flex to create and manage Symfony applications.

Composer is the package manager used by modern PHP applications to manage their dependencies. Symfony Flex is a Composer plugin designed to automate some of the most common tasks performed in Symfony applications. Using Flex is optional but recommended because it improves your productivity significantly.

Best Practice

Use the Symfony Skeleton to create new Symfony-based projects.

The Symfony Skeleton is a minimal and empty Symfony project which you can base your new projects on. Unlike past Symfony versions, this skeleton installs the absolute bare minimum amount of dependencies to make a fully working Symfony project. Read the Installing & Setting up the Symfony Framework article to learn more about installing Symfony.

Creating the Blog Application

In your command console, browse to a directory where you have permission to create files and execute the following commands:

1
2
$ cd projects/
$ composer create-project symfony/skeleton blog

This command creates a new directory called blog that contains a fresh new project based on the most recent stable Symfony version available.

Tip

The technical requirements to run Symfony are simple. If you want to check if your system meets those requirements, read Requirements for Running Symfony.

Structuring the Application

After creating the application, enter the blog/ directory and you'll see a number of files and directories generated automatically. These are the most important ones:

1
2
3
4
5
6
7
8
9
10
11
12
blog/
├─ bin/
│  └─ console
├─ config/
└─ public/
│  └─ index.php
├─ src/
│  └─ Kernel.php
├─ var/
│  ├─ cache/
│  └─ log/
└─ vendor/

This file and directory hierarchy is the convention proposed by Symfony to structure your applications. It's recommended to keep this structure because it's easy to navigate and most directory names are self-explanatory, but you can override the location of any Symfony directory:

Application Bundles

When Symfony 2.0 was released, most developers naturally adopted the symfony 1.x way of dividing applications into logical modules. That's why many Symfony applications used bundles to divide their code into logical features: UserBundle, ProductBundle, InvoiceBundle, etc.

But a bundle is meant to be something that can be reused as a stand-alone piece of software. If UserBundle cannot be used "as is" in other Symfony applications, then it shouldn't be its own bundle. Moreover, if InvoiceBundle depends on ProductBundle, then there's no advantage to having two separate bundles.

Best Practice

Don't create any bundle to organize your application logic.

Symfony applications can still use third-party bundles (installed in vendor/) to add features, but you should use PHP namespaces instead of bundles to organize your own code.


Next: Configuration

This work, including the code samples, is licensed under a Creative Commons BY-SA 3.0 license.
TOC
    Version
    We stand with Ukraine.
    Version:
    Make sure your project is risk free

    Make sure your project is risk free

    Check Code Performance in Dev, Test, Staging & Production

    Check Code Performance in Dev, Test, Staging & Production

    Symfony footer

    ↓ Our footer now uses the colors of the Ukrainian flag because Symfony stands with the people of Ukraine.

    Avatar of vindby23, a Symfony contributor

    Thanks vindby23 for being a Symfony contributor

    1 commit • 4 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?

      • Symfony at a Glance
      • Symfony Components
      • Case Studies
      • 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

      • SymfonyConnect
      • Support
      • How to be Involved
      • Code of Conduct
      • Events & Meetups
      • Projects using Symfony
      • Downloads Stats
      • Contributors
      • Backers
    • Blog

      • Events & Meetups
      • A week of symfony
      • Case studies
      • Cloud
      • Community
      • Conferences
      • Diversity
      • Documentation
      • Living on the edge
      • Releases
      • Security Advisories
      • SymfonyInsight
      • Twig
      • SensioLabs
    • Services

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

      Deployed on

    Follow Symfony

    Search by Meilisearch