Symfony is fast and leading PHP framework built on top of the Symfony Components. Drupal, phpBB, and eZ Publish frameworks also built on Symfony Components.
In this article, we will go through how to create new Symfony framework using composer command. We will also setup Symfony application and connect with MySQL database.
Before creating your first Symfony application you must have installed:
Create Symfony application
Run the below composer command to create new symfony application.
composer create-project symfony/website-skeleton my_project
Now go to the project folder
If you need to know more details about Symfony project, use the below command.
php bin/console about
In the root path, copy .env.test file to .env and add the below database details in it.
You will also need to configure Symfony with apache web server. For the live server, you will need fully-featured web server. Run the below command to install apache symfony pack.
composer require symfony/apache-pack
This will add .htaccess file in public folder. You should define all apache rules in that file.
To run Symfony commands, you can do anything from the below.
Use it as a local file:
Or add the following line to your shell configuration file:
Or install it globally on your system:
mv /home/jitesh/.symfony/bin/symfony /usr/local/bin/symfony
Run the below command to start symfony server
And open web browser and open http://localhost:8000/. You will see welcome page.
Copyright 2023 HackTheStuff