Symfony 4.4 released! Still among top web development frameworks?

Symfony is one of the oldest PHP frameworks and dates back to 2005. Since then, there have been lots of iterations that brought-back life into this web application framework. Symfony is not just one of the best web development frameworks, but also a set of PHP components that are used for all kinds of purposes: from web application to CMS development.

Symfony 4.4 is one of the final iterations to the Symfony web development framework, and would subsequently lead to the launch of Symfony 4.0 in November this year.

Here is everything new about Symfony 4.4, and our predictions on how these improvements will impact businesses’ preference to hire PHP developers for working on the Symphony PHP web development framework.

1. Improvements in Redis Cache

Redis is an open-source in-memory data structure store that is used as a database, a cache, and a message broker. It is also an adapter of the Symfony Cache component, which has seen a lot of improvements with Symfony 4.4.

One of the major improvements with Redis is the included support for Redis Sentinel in Symfony 4.4. Redis Sentinel is a distributed system that exists to prevent failures even without human interference and keep the system robust and safe from errors. Sentinel is also capable of performing other functions such as monitoring, delivering notifications and acting as a configuration provider for clients.

To use Redis Sentinel, a developer needs to add the redis_sentinel option to the Redis Connection DSN;

use Symfony\Component\Cache\Adapter\RedisAdapter;

// set the 'redis_sentinel' parameter to the name of your service group
$client = RedisAdapter::createConnection(
'redis:?host[redis1:26379]&host[redis2:26379]&host[redis3:26379]&redis_sentinel=mymaster'
);

Other improvements in Redis cache come in the form of enhancements in Redis Tag Aware Adapters. These are used for invalidating cache based on tags rather than expiration time. Here’s what has changed with the RedisTagAwareAdapter in Symfony 4.4 web development framework:

The Redis requirement has been lowered to V2.8 and certain phpredis versions are no longer needed anymore.
The per tag constraint has been increased to 4 billion keys per tag from the existing 2 billion keys per tag constraint. The invalidation process has been improved to negate the leaving of unused keys that consume memory over time. Delete operations are now faster as they’re reduced to a single round-trip instead of two linear trips.

2. New Welcome Page

When a developer starts a new project n Symfony web development framework, they’re shown a welcome screen that highlights the directory of the application, a link to documentation and a confirmation message which informs that Symfony is successfully installed.

But until now, the look of this welcome page was dull at best. Symfony 4.4 brings with it a few design changes which make the welcome page look more lively and inspiring.

The welcome page now has a better, responsive design and also has links to access additional resources such as complete documentation, tutorials, and the community forum. Another fun addition is the random color change which occurs every time a user reloads the page.

3. Improvements in Event Listeners

Several events are initiated by Symfony web development framework during the request-response flow. Event listeners and event subscribers allow developers to execute certain code for responding to such events.

Developers usually prefer event subscribers as these can listen to multiple events and don’t require any specific configuration in cases when autoconfiguration is running. Symfony 4.4 comes with improvements in event listeners so developers can configure them even more easily.

4. New Horizontal Table console command

Among the new features added in Symfony 4.4 web development framework are Horizontal tables and new definition lists. Let us first see how a Horizontal table is implemented.

Here’s a sample code for a generic table:

use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Helper\Table;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
// ...

class SomeCommand extends Command
{
public function execute(InputInterface $input, OutputInterface $output)
{
$table = new Table($output);
$table
->setHeaders(['ISBN', 'Title', 'Author'])
->setRows([
['99921-58-10-7', 'Divine Comedy', 'Dante Alighieri'],
['9971-5-0210-0', 'A Tale of Two Cities', 'Charles Dickens'],
['960-425-059-0', 'The Lord of the Rings', 'J. R. R. Tolkien'],
['80-902734-1-6', 'And Then There Were None', 'Agatha Christie'],
])
;
$table->render();
}
}

The output looks like this:

+---------------+--------------------------+------------------+
| ISBN          | Title                    | Author           |
+---------------+--------------------------+------------------+
| 99921-58-10-7 | Divine Comedy            | Dante Alighieri  |
| 9971-5-0210-0 | A Tale of Two Cities     | Charles Dickens  |
| 960-425-059-0 | The Lord of the Rings    | J. R. R. Tolkien |
| 80-902734-1-6 | And Then There Were None | Agatha Christie  |
+---------------+--------------------------+------------------+

As you can see, this is just a normal vertical table. To change it into a horizontal table, we only have to use the newly added setHorizontal(bool $horizontal = true) method:

$table
->setHeaders(['ISBN', 'Title', 'Author'])
->setRows([
// ... the rows ...
])
->setHorizontal()
;

And Voila! Now we can see a horizontal table, in which already existing data is shown in rows instead of columns as in the previous case.

 

+--------+-----------------+----------------------+-----------------------+--------------------------+
| ISBN   | 99921-58-10-7   | 9971-5-0210-0        | 960-425-059-0         | 80-902734-1-6            |
| Title  | Divine Comedy   | A Tale of Two Cities | The Lord of the Rings | And Then There Were None |
| Author | Dante Alighieri | Charles Dickens      | J. R. R. Tolkien      | Agatha Christie          |
+--------+-----------------+----------------------+-----------------------+--------------------------+

5. Signing & Encryption features in mail

Symphony 4.3 introduced Mailer and Mime components as a replacement to SwiftMailer. Symfony 4.4 web development framework takes it further with tweaks that now let users sign and encrypt email messages using the S/MIME standard.

This feature is highly important as signing and encryption allow for enhanced authentication and security of email messages.

Signing: A sign on a mail using Symfony 4.4 uses a digital signature of a hash of all mail contents. This helps ensure that any original content isn’t tampered with.

use Symfony\Component\Mime\Crypto\SMimeSigner;
use Symfony\Component\Mime\Email;

$email = (new Email())->from('...')->to('...')->html('...');

$signer = new SMimeSigner('/path/to/certificate.crt', '/path/to/certificate-private-key.key');
$signedEmail = $signer->sign($email);
// now use the Mailer to send this $signedEmail instead of the original $email

Encryption: The encryption feature improves the security of all attachments as they’re only accessible through a private key.

use Symfony\Component\Mime\Crypto\SMimeEncrypter;
use Symfony\Component\Mime\Email;

$email = (new Email())->from('...')->to('...')->html('...');

$encrypter = new SMimeEncrypter('/path/to/certificate.crt');
$encryptedEmail = $encrypter->encrypt($email);
// now use the Mailer to send this $encryptedEmail instead of the original $email

Is Symfony still among the best web development frameworks?

These are the major improvements in Symfony 4.4, and it is still one of the best PHP and web development frameworks out there. Most of these additions will go a long way in keeping Symfony alive. In fact, Symfony 4.4 is just a prelude to its next evolution- Symfony 5, expected to arrive early next year.

About the Author

Mantra is a Business Consultant & strategic thought leader bridging the divide between technology and client satisfaction. With 12 years of knowledge, innovation and hands-on experience in providing consultations to Startups, ISVs & Agencies who need dedicated development & technology partners. He has also lead to the delivery of countless successful projects.
Blogging is his passion & he shares his expertise here through ValueCoders.. Follow him on Twitter & LinkedIn

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.