How to create Symfony project

  • avatar
  • 473 Views
  • 3 mins read

Symfony is a PHP web application framework and a set of reusable PHP components/libraries. Symfony aims to speed up the creation and maintenance of web applications and to replace repetitive coding tasks. It's also aimed at building robust applications in an enterprise context, and aims to give developers full control over the configuration: from the directory structure to the foreign libraries, almost everything can be customized.

Prerequisites

  • PHP 7.2.5 or higher and these PHP extensions (which are installed and enabled by default in most PHP 7 installations): Ctype, iconv, JSON, PCRE, Session, SimpleXML, and Tokenizer. Take a look on how to install PHP-FPM on Ubuntu.

  • Composer is used to manage Symfony dependencies. Take a look on how to install Composer on your computer.

Installation

First you must download and run this installer to create a binary called Symfony:

wget https://get.symfony.com/cli/installer -O - | bash && export PATH="$HOME/.symfony/bin:$PATH"

Then you can run this command and it will create a new project in new_app folder (in the current location) and install dependencies:

symfony new new_app --full

The --full option installs all the packages that you usually need to build web applications, so the installation size will be bigger. You can skip it if you are building a microservice, console application or API.

Using Symfony

After the application has been created, you may start Symfony's local development server using:

cd new_app && symfony server:start

We will see that our terminal will be blocked by the process and will show us the URL to access the APP from any browser installed on our computer. Usually it will be something similar to http://127.0.0.1:8000

symfony_server_start.png

To unlock the terminal and stop the execution we can use the Ctrl+C combination on our keyboard.

 Join Our Newsletter

Get the latest news and popular articles to your inbox every month

0 Comments

Leave a Reply

Your email address will not be published.