Codementor Events

Building A Basic To-Do Application With Symfony 3- Part 1

Published Mar 09, 2019
Building A Basic To-Do Application With Symfony 3- Part 1

This tutorial will be talking about an awesome framework of PHP called Symfony. I know many developers might be surprised about this framework because it is not as popular as Laravel, Codeigniter, Yii and other popular PHP frameworks but let me shock you. Laravel uses many components of Symfony. Drupal, a popular content management system, is built on Symfony. One cool thing about Symfony that interests me is that apart from the fact that it is a web framework, you can use Symfony to build reusable PHP components for your projects. You can learn about other awesome stuffs you can build with Symfony here. In this series, my aim is to introduce you to the cool features of the framework by building a basic To-Do Application. In the first part of this tutorial, I will teaching you how to set up a Symfony 3 application and run your first Symfony Application.

Requirements

  • PHP (>= 5.6)
  • Apache2
  • MYSQL
  • Text Editor
  • Smiling face 😃

Setup

I am going to be using Ubuntu 16.04(Linux Distro) for this tutorial. So, the setup in this tutorial will be targetted at Linux and Mac OS users but for Windows users, it is pretty easy to setup. You can get more about the setup here. To setup, follow the following steps:

  • Run the following commands below in your terminal.
sudo mkdir -p /usr/local/bin sudo curl -LsS https://symfony.com/installer -o /usr/local/bin/symfony sudo chmod a+x /usr/local/bin/symfony

The commands above create a bin directory in the system usr/local folder then it installs symfony into the folder and then sets permission mode.

  • To test if symfony has been installed, run the following command below in a new terminal.
symfony

You should see something like this then you are good to go.

Create Application

At this point, we are ready to create a new symfony project for our To-Do application. We will do this by following the following steps:

  • Run the following commands in terminal.
mkdir projects
cd projects
symfony new todo-app 3.0

What the last command does is to create a new symfony project with the name todo-app and then with version 3.0. Once you see something like this below, the application has been installed successfully and with that, we can go on to running our appllication.

Run Application

Since we have our application installed already, what we should do next is to check out how to run our app on our browser and some key things about running Symfony applications. First, run the following commands in the terminal you used to download the smyfony project.

cd todo-app
php bin/console server:run

What the commands will do is take you into the applications folder called todo-app then the last command puts the local server in action for the application to work.

To test if the application works, go to your browser and type http://127.0.0.1:8000/ and see what it brings out.

Yiipee!!!! You should see something like the below and this shows your application is set up.

Before I end the first part of this tutorial, I want to advice that you run your application with app_dev.php attached to the url before anything else. For example, with this http://127.0.0.1:8000/app_dev.php/ you will still get the same result but the advantage of attaching app_dev.php to the url is for Symfony to understand that you are working in the development environment. So, it will give your application a development environment friendly configuration.

Don't Miss Out On The Other Parts Of The Tutorial

Building A Basic To-Do Application With Symfony 3- Part 2
Building A Basic To-Do Application With Symfony 3- Part 3

Like this article? Follow @goodnesskayode on Twitter

Discover and read more posts from Goodness Kayode
get started
post commentsBe the first to share your opinion
Show more replies