Skip to content

Latest commit

 

History

History
164 lines (111 loc) · 5.28 KB

setup.rst

File metadata and controls

164 lines (111 loc) · 5.28 KB

single: Installing and Setting up Symfony

Installing & Setting up the Symfony Framework

Screencast

Do you prefer video tutorials? Check out the Stellar Development with Symfony screencast series.

To create your new Symfony application, first make sure you're using PHP 7.1 or higher and have Composer installed. If you don't, start by installing Composer globally </setup/composer> on your system. If you want to use a virtual machine (VM), check out Homestead </setup/homestead>.

Create your new project by running:

$ composer create-project symfony/website-skeleton my-project

This will create a new my-project directory, download some dependencies into it and even generate the basic directories and files you'll need to get started. In other words, your new app is ready!

Tip

The website-skeleton is optimized for traditional web applications. If you are building microservices, console applications or APIs, consider using the much simpler skeleton project:

$ composer create-project symfony/skeleton my-project

# optional: install the web server bundle (explained next)
$ cd my-project
$ composer require --dev symfony/web-server-bundle

Running your Symfony Application

On production, you should use a web server like Nginx or Apache (see configuring a web server to run Symfony </setup/web_server_configuration>). But for development, it's convenient to use the Symfony PHP web server <setup/built_in_web_server>.

Move into your new project and start the server:

$ cd my-project
$ php bin/console server:run

Open your browser and navigate to http://localhost:8000/. If everything is working, you'll see a welcome page. Later, when you are finished working, stop the server by pressing Ctrl+C from your terminal.

Tip

If you're having any problems running Symfony, your system may be missing some technical requirements. Use the Symfony Requirements Checker </reference/requirements> tool to make sure your system is set up.

Tip

If you're using a VM, you may need to tell the server to bind to all IP addresses:

$ php bin/console server:start 0.0.0.0:8000

You should NEVER listen to all interfaces on a computer that is directly accessible from the Internet.

Storing your Project in git

Storing your project in services like GitHub, GitLab and Bitbucket works like with any other code project! Init a new repository with Git and you are ready to push to your remote:

$ git init
$ git add .
$ git commit -m "Initial commit"

Your project already has a sensible .gitignore file. And as you install more packages, a system called Flex <flex-quick-intro> will add more lines to that file when needed.

Setting up an Existing Symfony Project

If you're working on an existing Symfony application, you only need to get the project code and install the dependencies with Composer. Assuming your team uses Git, setup your project with the following commands:

# clone the project to download its contents
$ cd projects/
$ git clone ...

# make Composer install the project's dependencies into vendor/
$ cd my-project/
$ composer install

You'll probably also need to customize your .env <config-dot-env> and do a few other project-specific tasks (e.g. creating database schema). When working on a existing Symfony app for the first time, it may be useful to run this command which displays information about the app:

$ php bin/console about

Checking for Security Vulnerabilities

Symfony provides a utility called the "Security Checker" to check whether your project's dependencies contain any known security vulnerability. Check out the integration instructions for the Security Checker to set it up.

The Symfony Demo application

The Symfony Demo Application is a fully-functional application that shows the recommended way to develop Symfony applications. It's a great learning tool for Symfony newcomers and its code contains tons of comments and helpful notes.

To check out its code and install it locally, see symfony/symfony-demo.

Start Coding!

With setup behind you, it's time to Create your first page in Symfony </page_creation>.

Go Deeper with Setup

page_creation

setup/homestead setup/built_in_web_server setup/web_server_configuration setup/composer setup/*