Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Tomas Votruba:
Introducing Symfony Flex Loader
Dec 21, 2018 @ 15:40:58

In a post to his site Tomas Votruba introduces something that can be helpful for those working with Symfony 4 and Flex to make the "zero-setup configuration" easier to work with: effective use of the Symfony Flex Loader.

Symfony 4 and Flex is heading in direction of zero-setup configuration - no bundles, no extensions, no configuration. You already know how to get rid of Configuration. Flex now loads services instead of Extension class.

But it has an extra price, a lot of new boilerplate code in Kernel. Today you'll learn how to keep your Kernel Flex-ready and clean at the same time.

He starts with an example kernel that loads an extra directory (defined by a "custom path"). He shows how to refactor these examples to "make them small again" making use of the Flex loader package that reduces the number of lines required to accomplish the same end result.

tagged: symfony symfony4 symfonyflex loader kernel tutorial package

Link: https://www.tomasvotruba.cz/blog/2018/12/20/introducing-symfony-flex-loader/

Jolicode.com:
How to Mix Security and Form with Symfony
Sep 21, 2018 @ 17:37:39

On the Jolicode.com blog, there's a tutorial they've posted showing how to "mix security and forms" in a Symfony application to show only certain form fields based on a user's roles.

In some applications, it could be required to disable some form fields depending on user’s roles.

In this article, we will see how to implement this feature thanks to a simple example: a blog engine.

For their example, they use a Symfony 4 application with the MakerBundle and create a basic blog with "article" entities and an "admin" entity for the user list. From there, the post includes the code needed to update the buildForm method in the ArticleType class to check the current user and be sure they have the "admin" role. To make this work, they also build out a SecurityExtension form extension class that performs the actual check. This is then hooked into the pre-submit event on the form to prevent other issues where an attacker might delete the "allowed" element and submit the data anyway. The post wraps up with an example of performing a similar check but hiding the field instead of just disabling it in the form.

tagged: security symfony symfony4 tutorial form builder admin check

Link: https://jolicode.com/blog/how-to-mix-security-and-form-with-symfony

TheCodingMachine.io:
Building a Single-Page Application with Symfony 4, Vue.js, Vue Router, Vuex and
Sep 11, 2018 @ 15:20:32

On The Coding Machine site author Julien Neuhart has written up a tutorial showing how to create a single-page application using Symfony 4 along with Vue.js, the Vue router, Vuex and Axios.

With Symfony, I used to build my web applications in a traditional way: the framework handles everything, from the routing to the page rendering. However nowadays web applications have complex user interactions and the previous approach does not fit well for such cases. That's where single-page application architecture comes to the rescue.

The tutorial walks you through the creation of an application where users can post messages wrapped up in a nicer Docker-ized environment. He starts with the creation of the development environment and project structure including the Docker setup and installation of the needed dependencies. From there he starts in on the frontend, creating the Vue.js code for the application and moving to the backend for the initial Symfony index route. He shows the creation of the Vue routing, handing the requests in Symfony, the creation of the Post entities and API functionality.

The post also includes the addition of User entities with usernames/passwords for authentication and the Symfony routes to handle those requests. The tutorial ends with some improvements to the initial setup including user role addition, CSRF tokens, error messaging and other Docker customizations.

tagged: tutorial symfony4 vuejs vuex vuerouter axios singlepage application

Link: https://thecodingmachine.io/building-a-single-page-application-with-symfony-4-and-vuejs

Symfony Blog:
Introducing the Symfony 4 certification
Mar 30, 2018 @ 15:50:26

On the Symfony blog, there's a new post that introduces a new certification targeted towards the latest release of the framework: the Symfony 4 certification.

Symfony 4 was released in November 2017, alongside new best practices and Symfony Flex, the new way to manage Symfony applications. This new version is so different from Symfony 3 that we've decided to introduce a new Symfony 4 certification program.

The Symfony 4 exam consists of 75 questions to be answered in 90 minutes or less and you can take the exam in any of the 4,000 test centers available worldwide. The list of topics covers the most important parts of the core framework, excluding third-party libraries like Doctrine, Monolog, etc. Depending on your results, you'll get the Advanced Certified badge or the more difficult Expert Certified badge.

They already have the vouchers on sale for the certification so you can take it and add that certification badge to your list. You can find out more about this and other Symfony certifications on the Symfony project certification site.

tagged: symfony certification symfony4 announcement

Link: http://symfony.com/blog/introducing-the-symfony-4-certification

Matthew Setter:
First Experiences with Symfony 4 & the Symfony Community
Mar 12, 2018 @ 17:45:14

Matthew Setter has a new post to his site sharing some of his experiences and interactions with Symfony 4 and it's community as someone new to the framework and community.

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.

He starts off describing some of his reasoning behind looking into Symfony, including the fact that a project at his work makes use of the framework. He then talks about getting started with v4 of the framework by reading the documentation, creating a core application and overcoming some of the common first-timer issues. He covers the use of templates, routing with annotations and using the bin/console to handle code generation. The post ends with some of his experiences with the community and their interaction with a tweet of his showing his appreciation for the framework.

tagged: symfony symfony4 experience community project introduction

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

Symfony Blog:
New in Symfony 4.1: Fastest PHP Router
Feb 16, 2018 @ 16:48:33

On the Symfony blog they have a post covering the result of some changes to how the framework handles incoming requests in Symfony 4: a performance and speed increase in the router making it even better than before.

Symfony 4 is the fastest PHP framework according to independent benchmarks, but we are continuously working on making it faster. In Symfony 4.1, we improved the Routing component to make it much faster when matching incoming URLs.

The post starts with a look at the two functional pieces of route handling: the generation of a URL to match and the matching the framework performs. Symfony 4 has sped things up by creating a "matcher" class during the compilation phase using some of these suggestions. The biggest change was to modify the regular expression URL matching to combine all patterns into one, reducing the number of calls to preg_match and locate the correlating route. The new routing requires no changes in your current Symfony 4 application, it just makes all of the updates it needs behind the scenes during compilation.

tagged: symfony symfony4 router speed performance regularexpression

Link: http://symfony.com/blog/new-in-symfony-4-1-fastest-php-router

Symfony Blog:
The end of Silex
Jan 12, 2018 @ 17:28:59

On the Symfony blog there's a quick post from Fabien Potencier (a sort of follow-up to this one) that talks about the end of Silex, a popular Symfony-based microframework, now that Symfony 4 and Flex exist.

What about Silex in a Symfony 4 world? During the last few months, and as an exercise when working on Flex, I have migrated several applications from Silex to Symfony 4. And the conclusion is that Symfony 4 feels like using Silex.

Using Symfony 4 and Flex feels as lightweight as using Silex. [...] Moving away from Silex is also made simpler as Symfony 4 almost auto-configure all your services. [...] For all these reasons, I would say that Silex is not needed anymore. So, we've decided to not support Symfony 4 in Silex, or at least not add the new features added in 3.4.

The comments on the post seem mostly supportive of the decision, realizing that what Symfony 4/Flex bring to the table all but replaces Silex anyway. A migration guide is in the works but hasn't been completed yet at the time of this posting (see this issue for the latest updates on that guide).

tagged: silex microframework symfony project symfony4 symfonyflex endoflife

Link: http://symfony.com/blog/the-end-of-silex

Symfony Blog:
The end of the Symfony Standard Edition
Jan 10, 2018 @ 17:54:34

On the Symfony blog there's a post with a major announcement for the users of the framework - the end of the Symfony Standard Edition, a release version that tried to bundle in the common tools a developer might need.

When I started to work on Symfony 2 many moons ago, I decided to create a set of decoupled components instead of a monolith framework like symfony 1. This choice was probably one of the key reasons of the immediate success of Symfony 2. [...] Of course, people don't want to assemble the components themselves when starting a new project. To fill the gap, we created the Flex was born. [...] Thanks to the new Flex approach, we've decided to not provide the Symfony Standard Edition for Symfony 4.0.

In the post Fabien talks about some of the history behind the Standard Edition including why it was made and what problems it solved. He then points out that, with the introduction of Flex, many of the issues and flexibility the SE lacked are worked out. While it is a little more complex to get started with a Flex application, the unpacking functionality helps with bringing in bundles of packages related packages without having to require each individually.

tagged: symfony standard edition endoflife end community flex symfony4

Link: https://symfony.com/blog/the-end-of-the-symfony-standard-edition

Fabien Potencier:
Symfony 4: Unpack the Packs
Jan 04, 2018 @ 17:53:47

Fabien Potencier of the Symfony project has a post on his site that introduces Symfony Packs, groupings of useful packages that can enhance the functionality of your application without having to manually load each package individually.

We get a lot of positive feedback on Symfony 4. You love the new directory structure. You love the simplicity of using services without configuring anything. And you love the automation that Flex provides. It makes me happy and proud.

[...] But one issue I hear sometimes is that it is more complex to start a new project. [...] You loved the simplicity of starting a project with the Symfony Standard Edition. Is it nostalgia? Perhaps. Would it be possible to get the best of both world? Certainly!

The Packs are "metapackages" that Composer uses to bundle dependencies together that relate either in functionality or as defined by a custom configuration. The article gives an example using the symfony/orm-pack pack and talks about how you can use it as-is or you can "unpack" it into its separate packages and automatically update the composer.json with the result.

tagged: symfony symfony4 pack composer metapackage introduction

Link: http://fabien.potencier.org/symfony4-unpack-the-packs.html

Knp University:
The Flex composer.json File
Dec 26, 2017 @ 17:51:50

For those looking to make the move up to Symfony 4 and Flex the Knp University site has a new post that sheds some light on the composer.json configuration for Flex and how to use it to install a complete Symfony 4 application.

We need to make our composer.json file look like the one from symfony/skeleton. Actually, go to "Releases", find the latest release, and then click to browse the files. Now we can see the stable composer.json contents.

So... yea, this one file is all you need to start a new project. That's crazy! Flex builds the project structure around it.

The article then talks about the major changes including dropping the symfony/symfony package, how to synchronize the rest of the composer.json and autoloading updates. It ends with a brief mention of how to then scaffold out the full application structure - one command, a Composer update.

tagged: composer symfony4 symfonyflex tutorial update changes

Link: https://knpuniversity.com/screencast/symfony4-upgrade/flex-composer.json


Trending Topics: