Posts tagged with symfony

Join 9,500+ smart developers

Every month I share what I learn from running Spatie, building Oh Dear, and maintaining 300+ open source packages. Practical takes on Laravel, PHP, and AI that you can actually use.

"Freek publishes a super resourceful and practical newsletter. A must for anyone in the Laravel space"

Joey Kudish — Shipping with AI as a teammate

No spam. Unsubscribe anytime. You can also follow me on X.

First Experiences with Symfony 4 & the Symfony Community

Getting to know another framework and community can be a daunting task. But in case of Symfony it proves not to be that hard. On his blog Matthew Setter shares his first steps into Symfony.

Recently, I decided to learn the basics of the Symfony (4) framework, so that I could better understand one of my client's applications, and provide better support to it. I never expected to use such a well-rounded framework. Nor did I expect to encounter such an engaged and supportive community. Here's the story.

https://www.matthewsetter.com/first-experience-with-symfony/

Read more

Symfony 4: New Hope

In an article on his Medium blog, Jerzy Zawadzki wrote about the most important changes made in Symfony 4.

Internally, Symfony 4.0 is “just” Symfony 3.4 with removed depracations. But from outside there is a big leap forward. Most changes (from the installation process, directory structe through using bundles, to coding itself) were made to improve Developer Experience with the framework. Such system like Symfony, which can be used to create web apps as easily as to build other frameworks on top of it, must be complicated. But, as Symfony proves in new version, this complexity may be ‘hidden’ from the developer eyes.

https://medium.com/@zawadzki.jerzy/symfony-4-new-hope-dbf99dde91d8

Read more

Symfony now has an improved dump function original

by Freek Van der Herten – 2 minute read

Let's talk a little bit about Symfony's dump function. It's part of their VarDumper component. The function can dump a variable to the screen or browser in a nicer format than PHP's native var_dump. In the recently released Symfony 3.4 and Symfony 4 the function got a nice little improvement that…

Read more

Taylor Otwell on Laravel and Symfony

In a recent interview published on the Cloudways blog Taylor Otwell shares his thoughts on the similarities differences between Laravel and Symfony.

Both Laravel and Symfony are more rapid than building an entire PHP application from scratch. So, in that sense, they both allow rapid application development. However, Laravel does make strong efforts to have a very clean and productive working environment for building applications of all sizes. I think Symfony has also made efforts in this direction over the last few years with their “DX” initiatives and some of the more opinionated things they are doing with Symfony Flex.

https://www.cloudways.com/blog/taylor-otwell-interview/

Read more

Symfony Routing performance considerations

On his blog Frank De Jonge explains how he solved a performance problem in one of his projects.

Last week I took a deep dive into Symfony's Routing Component. A project I worked on suffered from a huge performance penalty caused by a routing mistake. This lead me on the path to discovering some interesting performance considerations. Some common practices align nicely with Symfony's optimisations, let's look into those.

https://blog.frankdejonge.nl/symfony-routing-performance-considerations/

Read more

Symfony and Laravel will require PHP 7 soon

According to Fabien Potencier, lead of the Symfony project, the next major version of Symfony, to be released at then end of 2017, will require PHP 7.

But Laravel will drop PHP 5 support even sooner. Taylor Otwell, the creator of Laravel, announced that Laravel 5.5, to be released in June 2017, will leave PHP 5 behind.

On multiple occasions Taylor et co. have stated that they don't like the strictness that things like scalar and return type hints bring to the table. So I don't expect to see them appear much in Laravel codebase. Smaller syntax improvements like for example the null coalescing operator will almost certainly be used.

A few weeks ago Jordi Boggiano reported that only a miserable 3% of all packages present on Packagist require PHP 7. The best thing about Symfony and Laravel dropping PHP 5 support is that it will send a strong message throughout the entire PHP ecosystem that you shouldn't bother with PHP 5 code anymore. When creating new projects and packages more developers will target PHP 7 as a minimum version as well.

For our PHP and Laravel packages we left PHP 5 behind as soon as PHP 7 was available. Our packages already make extensive use of return type hints, anonymous classes and the null coalescing operator to create more readable (and thus more maintainable) code.

(Fun Scary fact: Wordpress only requires PHP 5.2 ?)

Read more

Symfony components in a legacy PHP application

Joeri Verdeyen, a developer at Yappa, explains how you can use some Symfony components in a legacy application.

Symfony Components are a set of decoupled and reusable PHP libraries. They are becoming the standard foundation on which the best PHP applications are built. You can use any of these components in any of your applications independently from the Symfony Framework.

The purpose of this post is to roughly describe how to implement some of the Symfony Components.

http://tech.yappa.be/symfony-components-in-a-legacy-php-application

Alternatively if you want to use Laravel's Illuminate components, check out Matt Stauffer's Torch repository on GitHub.

Read more

A better way to style the output of console commands

When creating output from a Symfony based console command you might have created a title using code like this:

$output->writeln('');
$output->writeln('<info>Lorem Ipsum Dolor Sit Amet</>');
$output->writeln('<info>==========================</>');
$output->writeln('');

Starting from Symfony 2.7 there's a nice way to style the output of console commands. This code produces the same output as the example above

$io = new SymfonyStyle($input, $output)
$io->title('Lorem Ipsum Dolor Sit Amet');

There are styles for titles, sections, questions, tables, and so on. Take a look at the documention to learn what's possible.

Read more

How to perform a HTTP/2 Server Push with the Symfony HttpKernel

HTTP/2 has a great feature called server push. It enables the server to send multiple responses in parallel for one request. In a blogpost on the Symfony Finland blog Jani Tarvainen demonstrates how to make use of server push with the Symfony Kernel.

$app->get('/images'), function () use ($app) {
    $images = array('/images/1.jpg','/images/2.jpg','/images/3.jpg');
    $response = new JsonResponse($images);
    foreach($images as $image){
        $response->headers->set('link','<' . $image . '>; rel=preload; as=image',false);
    }
    
    return $response;

Read the entire article for some more background info.

Read more

Running Symfony2 on PHP7

This chart shows the number of requests per second that were performed (more is better). You can see that PHP 7 can do a lot more in comparison with the other versions. Response times drop from 0.2269 to 0.0865 seconds in the production environment.
http://www.intracto.com/nl/blog/running-symfony2-on-php7

Nice benchmark-work by Tom Van Looy. It is clear that you'll benefit from impressive speed bumps when upgrading to the next major version of PHP. Tom also provides instructions on how to setup PHP7 so you can perform your own tests.

Read more