Symfony is a powerful framework with DI features. The currently popular PHP development frameworks Drupal and Laravel all use symfony at the bottom. Think about it Learn more about symfony, portal
Installing symfony is very simple, there are generally two ways, you can choose at will
1. Use symfony installer to install directly (recommended)
According to different operating systems, the installation is slightly different
1.Linux/Mac OS
Execute the following command on the console:
1 2 |
|
Will create a global command symfony
in your operating system2.Windows (can be skipped)
Execute the following command on the console:
1 |
|
Move the downloaded symfony file to your project directory, and then execute the following command:
1 2 |
|
3. Create a symfony application
Use new command to create the first symfony application
1 2 3 4 5 6 |
|
2. Use composer to install symfony
If your PHP version is lower than 5.4, the first method is not suitable for you. You can consider upgrading the PHP version and continue to use the first method. You can also consider using composer to install it.
What is composer?
If you are familiar with java’s maven, ruby’s gem, python’s pip, and nodejs’ npm, you will of course understand it at a glance.
Yes, composer is a dependency management tool tailored for the PHP language. If you want to quickly learn about composer, use the portal
1. Install composer
Composer requires php5.3.2 to run
Linux/Mac
1 |
|
It is recommended to execute the following command
1 |
|
In this way, composer becomes a global command and can be executed anywhere and input composer
Windows
Quick automatic installation
Download and run the composer-setup.exe program, next step, you know. Finally, don’t forget to set the path
2. Use the create-project command to create a symfony application
1 |
|
If you want to specify the symfony version to install, add a parameter at the end of the command
e.g
1 |
|
Okay
symfony installed successfully
Let’s visit the welcome page!
symfony has an internal test server. You can start the server by executing the following command
1 2 |
|
After the server is started, enter localhost:8000 in the address bar, and you will see the welcome to symfony interface.
Finally you want to stop the server, then just do this
1 |
|
Possible questions:
If you get an error when executing php app/console server:run
You only need to find the AppKernel.php file under the app folder and add a method at the end of the file:
1 2 3 4 5 |
|
After saving, restart the server (php app/console server:run) and you are done.