I recently had to install Symfony, the PHP component-based framework, for a work project. There is extensive documentation on the Symfony site, however I thought I would post a quick start guide with the essential steps for getting Symfony up and running quickly on a Windows server environment.
I chose Symfony because it was the least framework-like method for structuring a PHP application. In reading Josh Lockhart’s ‘Modern PHP’ this past year, he notes that the problem in choosing a traditional framework is that you are committing to that framework’s future. Additionally, frameworks have a wide variety of tools, but sometimes you just need something specific, which the framework may not provide. Symfony, on the other hand, is a collection of decoupled components that can be used in isolation or as part of a framework.
The easiest way that I found to install Symfony is with Composer, the dependency management tool for PHP.
There are three steps: install Composer, create a Symfony project, and start the server.
1. Go to the Composer site and download and run the application via the executable.
2. Open a Windows command prompt and enter the following command (change ‘project_name’ to whatever you want to call your project):
composer create-project symfony/framework-standard-edition project_name
Composer will then execute a series of commands. At some point it will ask you for database credentials. You can hit enter for each one to leave them at their defaults initially. Of course, before moving to a production environment you will want to change these.
Eventually, you will get a message saying all assets were successfully installed.
3. Finally, navigate to your directory and start the server with the following two commands (for ‘project_name’ enter whatever you named your project in step two):
php bin/console server:run
Symfony should now be installed. You can verify this by pulling up http://localhost:8000/ in your browser, where you will get a Symfony welcome message.