Symfony Components, the building blocks of the future!

Symfony Components are separate PHP libraries that can be used for multiple applications. These Components are so well written that they have become the foundation upon which the best PHP applications can be built. These components can be installed with composer. Composer is a dependency manager for PHP. This is the best way to keep track of all your dependencies.


Earlier we published an article about Symfony, referring to the Symfony Components. In this article I will tell you more about this.


The Symfony Components are a number of separate reusable PHP libraries. These Components are so well constructed that they have become the foundation on which the best PHP applications can be built.


The Symfony Components can be installed via Composer.


Composer is a dependency manager for PHP. Composer takes care of all the dependencies in your project for you. It neatly retrieves all the components you need for your project and all the libraries on which that component depends.


Package management is a well-known concept and much of composer is inspired by npm van Node.js and bundler of Ruby


However, now there are too many Components to cover them all, so we have selected the following: Asset, Config, Routing, Webpack Encore.


Asset Component

$ composer require symfony/asset

The Asset component takes care of things around creating URLs and versions of your so-called 'assets', such as your CSS and your JavaScript files.


In the past, the assets in a web page were often used in the following way:

link rel=”stylesheet” type=”text/css” href=”/css/main.css”

This approach is actually only recommended for small applications, hard-coding the URLs can quickly lead to irritation and problems.


For example, you have to type out the entire path for each asset. With the Asset component you can put assets in one package and distribute it. When moving an asset, you have to adjust all links and make sure you haven't forgotten any. In the Asset component you can easily change the location by changing the path of the package.


Config Component

$ composer require symfony/error-config

The Config component lets you search, combine and validate files of all kinds of file types.


Often if you have a PHP project that requires you to work with multiple services, it can be difficult to deal with all these different types of configuration files. With the Config component in Symfony this becomes a lot easier and saves you a lot of time.


Routing Component

$ composer require symfony/error-config

Het Routing component in Symfony is misschien wel de mooiste die er is. Het zorgt ervoor dat er aan de hand vaan een URL, bijvoorbeeld: /profiel/wijzigen/, een actie in de Controller (van het MVC model) kan uitvoeren. Dit betekent dat je ook SEO-friendly URL’s kan maken.


The URL is indicated above the method, also a name is indicated so that you can also use it in twig files.


With this component you can also specify the HTTP method so that the URL listens to it. If you don't specify anything then the URL will listen for any HTTP method (GET , POST, PUT, etc.)


In addition, there are many other great functions in this component, such as generating URLs, working extensively and smartly with parameters and sub-domain routing.


Webpack Encore

$ composer require symfony/webpack-encore

Webpack Encore is an easier way to get Webpack into your application, it allows you to bundle your JavaScript modules through an API, compile and minify your CSS and JS files.

In your webpack.config.js file you do the configuration for Webpack and Webpack Encore.


After configuring your files, you can run commands in the console to build assets. For the development environment you run the command:

$ yarn encore dev

This will then build the files and use them in a readable way, making it easy to debug your code in the Dev Tools in the browser.


For the production environment you can use this command:

$ yarn encore prod

This will optimize and minify all files to work as well as possible on the live application.

Read some of our blogs down here!

Expand your knowledge with the 4BIS Blog...

WordPress and Plugins – A world that opens up for you!

WordPress, Web development, Ecommerce / Webshop, Knowledge Base, WooCommerce

With plugins you can expand the functionality of WordPress or add completely new functions to WordPress. You can make plugins yourself, provided you know PHP, or you can download them.

Read more

Unveiling Tech-Nieuws.nl: Where Innovation Meets Ingenuity

SEO / SEA, Software Modernisation, Web development, PHP, Symfony, Digital Marketing

In the bustling realm of technology, staying updated is not just a necessity but a lifestyle. With an overflow of information bombarding us daily, having a reliable source to curate and present the latest tech news becomes invaluable. Enter Tech-Nieuws.nl,...

Read more

HR software: This is how you automate Human Resource Management

Business software, Software Modernisation, Web development, Automate

HRM, also known as Human Resource Management, is an important part for every company. Especially if you have many employees, an HR department is indispensable. However, it is not necessary to have a huge HR department. Much can be automated using HR...

Read more

And what can we do for you?_

Do you want to know more or are you interested? Please feel free to contact us directly, by phone or via mail.
Or use one of our contact forms so that we can answer you as quickly and appropriately as possible can give. We would love to hear from you!

back to top