Shopware Silver & extension partner
Certified Advanced Developers & solution architects
200+ E-commerce Rrojects
50+ Professional developers
The Symfony binary also provides a tool to check if your computer meets all requirements.
Before creating your first Symfony application you must: ●Install PHP 8.0.2 or higher, and these PHP extensions (which are installed and enabled by default in most PHP 8 installations): Ctype, iconv, PCRE, Session, SimpleXML, and Tokenizer; ●Note that all newer, released versions of PHP will be supported during the lifetime of each Symfony release (including new major versions). For example, PHP 8.1 is supported. ●Install Composer, which is used to install PHP packages. Optionally, you can also install Symfony CLI. This creates a binary called Symfony that provides all the tools you need to develop and run your Symfony application locally. The Symfony binary also provides a tool to check if your computer meets all requirements. Open your console terminal and run this command:
Open your console terminal and run any of these commands to create a new Symfony application: # run this if you are building a traditional web application
The only difference between these two commands is the number of packages installed by default. The web app option installs all the packages that you usually need to build web applications, so the installation size will be bigger. If you’re not using the Symfony binary, run these commands to create the new Symfony application using Composer: No matter which commands you run to create the Symfony application, all of them will create a new my_project_directory/ directory, download some dependencies into it, and even generate the basic directories and files you’ll need to get started. In other words, your new application is ready!
In addition to creating new Symfony projects, you will also work on projects already created by other developers. In that case, you only need to get the project code and install the dependencies with Composer. Assuming your team uses Git, set up your project with the following commands:
In production, you should install a web server like Nginx or Apache and configure it to run Symfony. This method can also be used if you’re not using the Symfony local web server for development. However, for local development, the most convenient way of running Symfony is by using the local web server provided by the Symfony binary. This local server provides among other things support for HTTP/2, concurrent requests, TLS/SSL, and automatic generation of security certificates. Open your console terminal, move into your new project directory and start the local web server as follows: Open your browser and navigate to http://localhost:8000/. If everything is working, you’ll see a welcome page. Later, when you are finished working, stop the server by pressing Ctrl+C from your terminal.
A common practice when developing Symfony applications is to install packages (Symfony calls them bundles) that provide ready-to-use features. Packages usually require some setup before using them (editing some files to enable the bundle, creating some files to add some initial config, etc.) Most of the time this setup can be automated and that’s why Symfony includes Symfony Flex, a tool to simplify the installation/removal of packages in Symfony applications. Technically speaking, Symfony Flex is a Composer plugin that is installed by default when creating a new Symfony application and which automates the most common tasks of Symfony applications. Symfony Flex modifies the behavior of the require, update, and remove composer commands to provide advanced features. Consider the following example: If you run that command in a Symfony application that doesn’t use Flex, you’ll see a Composer error explaining that logger is not a valid package name. However, if the application has Symfony Flex installed, that command installs and enables all the packages needed to use the official Symfony logger.
This is possible because lots of Symfony packages/bundles define “recipes”, which are a set of automated instructions to install and enable packages into Symfony applications. Flex keeps track of the recipes it installed in a Symfony.lock file, which must be committed to your code repository. Symfony Flex recipes are contributed by the community and they are stored in two public repositories: ●The main recipe repository is a curated list of recipes for high-quality and maintained packages. Symfony Flex only looks in this repository by default. ●The Contrib recipe repository contains all the recipes created by the community. All of them are guaranteed to work, but their associated packages could be unmaintained. Symfony Flex will ask your permission before installing any of these recipes. Read the Symfony Recipes documentation to learn everything about how to create recipes for your packages.
The Symfony binary created when you install Symfony CLI provides a command to check whether your project’s dependencies contain any known security vulnerability: A good security practice is to execute this command regularly to be able to update or replace compromised dependencies as soon as possible. The security check is done locally by fetching the public PHP security advisories database, so your composer.lock file is not sent on the network. The check:security command terminates with a non-zero exit code if any of your dependencies is affected by a known security vulnerability. This way you can add it to your project build process and your continuous integration workflows to make them fail when there are vulnerabilities.
The Symfony Demo Application is a fully-functional application that shows the recommended way to develop Symfony applications. It’s a great learning tool for Symfony newcomers and its code contains tons of comments and helpful notes. Run this command to create a new project based on the Symfony Demo application:
If you want to know more about e-commerce development platforms or apps, read our blog posts for Shopify and Shopware. Our dedicated outsourcing team can be your collaborator in ecommerce.