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

Community News:
KnpUniversity is now SymfonyCasts
Sep 17, 2018 @ 10:44:36

An announcement has been posted by KnpUniversity today under the group's new name: SymfonyCasts.

If you look around the site today, you'll probably notice something different. KnpUniversity is now SymfonyCasts! And SymfonyCasts is the official online training system for Symfony. This is something we've been planning for awhile and we are beyond excited. Like, jumping-high-fives-someone-order-a-big-cake kind of excited! Woh.

If you're already a KnpU/SymfonyCasts user: we <3 you! And because of that, I want to explain exactly what this change means (and doesn't mean).

They start by answering the first questions most have about changes and if they acquired. They also talk about why they're making the change and how the focus will still remain on high-quality Symfony-related tutorials and videos. With them joining the Symfony family officially, though, it provides them with support to keep the lessons coming and the help they'll provide on the Symfony documentation as a part of the changes.

tagged: knpuniversity symfonycasts announcement symfony

Link: https://symfonycasts.com/blog/symfonycasts

TutsPlus.com:
Set Up Caching in PHP With the Symfony Cache Component
Sep 13, 2018 @ 11:14:08

On the TutsPlus.com site today they've posted a new tutorial spotlighting one of the components that makes up the Symfony framework, the Symfony Cache Component - and how you can use it to improve the performance of your applications.

Today, I'll show you the Symfony Cache component, an easy way to add caching to your PHP applications. This helps improve the overall performance of your application by reducing the page load time.

[...] In this article, we'll explore how you can unleash the power of the Symfony Cache component. As usual, we'll start with installation and configuration, and then we'll go on to explore a few real-world examples in the latter half of the article.

The tutorial starts with a few basic terms you'll need to be familiar with to use the component. From there it's straight into the installation and configuration of the component. Code is then included showing a more "real world" example of caching several different kinds of data, fetching it and setting expiration times. It then walks through each line of the code explaining how it works and more context about what's happening behind the scenes.

tagged: symfony cache component tutorial introduction

Link: https://code.tutsplus.com/tutorials/set-up-caching-in-php-with-the-symfony-cache-component--cms-31498

Colin O'Dell:
Avoid Unsupported Symfony Component Versions With This Composer Metapackage
Sep 12, 2018 @ 11:55:05

In a new post to his site Colin O'Dell has shared a Composer "metapackage" that can help you avoid unsupported Symfony component versions with the help of Composer's own internal version checking system.

Using symfony/symfony makes Composer install all Symfony Components in the same version. But when using the standalone packages, Composer might install dependencies in a different major version - for example, symfony/validator v2.8 is compatible with symfony/translation v3.0.

This is fine if you don't want to stick strictly to Symfony LTS versions, but it does mean that you could end up using versions of components which no longer receive security updates.

Rather than having to specifically define (and manage) the versions of package you want to install, you could opt to install his package that will do the hard work for you. It uses the "conflict" handling in the Composer configuration to limit version numbers on many of the popular Symfony packages and requires them to be greater than or equal to certain versions.

tagged: symfony component composer metapackage unsupported versions check

Link: https://www.colinodell.com/blog/201809/avoid-unsupported-symfony-component-versions-composer-metapackage

Happyr.com Developer Blog:
Define Symfony access control rules in a database
Sep 11, 2018 @ 11:52:44

On the Happyr.com Developer blog Tobias Nyholm has written up a tutorial showing how you can use functionality included in the Symfony framework to define access control rules in a database using voters and values stored in the database.

I was recently at a PHP conference in Odessa where I met many great developers. One of them asked me a question, that the answer was not obvious. His use case was that he wanted to use Symfony's Access Control configuration to restrict access in his application. But he also wanted to configure the rules dynamically.

Since all the configuration in Symfony is cached with the container for performance reasons, we could obviously not allow a use a database to somehow “print” new configuration. We need to do something smarter.

Voters are a part of the Symfony security component and are set up as a service in the Symfony DI container. When a route is defined in the access_control section, the matching voter is called and the access granted/denied state is determined by values from the token and subject provided (from the database).

tagged: tutorial symfony access control database rules voter

Link: http://developer.happyr.com/define-access-control-in-database

Tomas Votruba:
4 Ways to Add Global Option or Argument to Symfony Console Application
Sep 04, 2018 @ 09:49:49

Tomas Votruba has a new post to his site showing you how to add a global option or argument to your application that makes use of the Symfony Console component. In this case, a "global" option is one that can be given to any command in the application. For his needs, it's a filename.

I'm working on 3 Console Commands. All was good, until I needed to add an argument to all commands at once... and in lazy, extensible, maintainable way.

He starts by talking about some of the "why" behind the need to run multiple commands at once. He shows an example of having multiple CHANGELOG files and the need to define the output file for each rather than just one file. He then goes through four different possible implementations, including the code and pros/cons of the approach:

  • Add Argument to Each Command
  • Modify Application Definition
  • The Symfony Event Subscriber Way
  • Extend the Application

He ends the post mentioning the one he prefers (the last one on the list) and briefly mentions anti-patterns and finding the right solution over just the first one you find.

tagged: symfony console application option global changelog tutorial

Link: https://www.tomasvotruba.cz/blog/2018/09/03/4-ways-to-add-global-option-or-argument-to-symfony-console-application/

TutsPlus.com:
How to Use the Symfony Filesystem Component
Aug 29, 2018 @ 11:02:44

The TutsPlus.com site has posted another tutorial spotlighting a component of the Symfony framework. In this latest tutorial they cover the Symfony Filesystem component, a module that provides useful wrapper functionality for common file system-related needs.

In this article, we're going to explore the Symfony Filesystem component, which provides useful methods to interact with a file system. After installation and configuration, we'll create a few real-world examples of how to use it.

The tutorial starts with a brief introduction of the component including a listing of functionality it provides. It then moves on to the installation (via Composer) and use in some sample code. From there they show how to use it to:

  • create a new directory
  • create a new file and add contents
  • copy a directory
  • remove a directory

Each of these includes both a code example and a brief summary of what's happening.

tagged: tutorial symfony filesystem component

Link: https://code.tutsplus.com/tutorials/how-to-use-the-symfony-filesystem-component--cms-31664

Tomas Votruba:
9 Features of Symfony Plugin You Should Not Miss in Gifs
Aug 24, 2018 @ 16:17:54

In a new post to his site Tomas Votruba goes into a "deep dive" of the functionality that the Symfony plugin for PhpStorm provides and some of the functionality it provides.

After very successful PHP 7.3 diffs post, let's dive to gifs of Symfony Plugin. You might know them, but they might surprise you like they did surprise me. Let's go!

He then walks through the installation process and some of the features the plugin includes:

  • Enabling the plugin (via the PhpStorm configuration)
  • Faster Translation Autocreate (TWIG)
  • Autocomplete Translation Key (TWIG)
  • Instant Service Autocomplete in YAML (YAML)
  • Forget The Tag (YAML)
  • Jump from Href to Route (TWIG)
  • Instant Route in Controller (PHP)
  • Faster Queries in Doctrine Repository (PHP)
  • Template Autocomplete (PHP)

For each item in the list, there are animated gifs provided showing it in action. You can find out more about the plugin on the JetBrains site.

tagged: phpstorm symfony plugin feature list ide tutorial

Link: https://www.tomasvotruba.cz/blog/2018/08/23/9-features-of-symfony-plugin-you-should-not-miss-in-gifs/#6-jump-from-href-to-route-twig

Symfony Blog:
The schedule for Symfony Loves PHP USA 2018 conference is released!
Aug 23, 2018 @ 12:37:44

On the Symfony blog they've posted an announcement about the release of the schedule for Symfony Loves PHP USA 2018, an event replacing SymfonyLive USA happening October 11th and 12th in San Francisco.

We’re super thrilled to announce that SymfonyLive USA becomes now Symfony Loves PHP USA conference!

Welcome to Symfony Loves PHP USA, the only conference dedicated to Symfony and PHP in the USA. We decided to change the conference name and its purpose to create a unique place in the USA where you can hear all the latest and best developments with Symfony and PHP! We aim to gather the American Symfony and PHP communities in San Francisco from October 11th to October 12th. We want you to come and feel welcome regardless your level of development with Symfony or PHP (beginner, advanced, intermediate).

Speakers at this year's event include:

  • Jordi Boggiano
  • Kristen Costagliola
  • Cal Evans
  • Jeremy Mikola
  • Dave Stokes
  • Jonathan Wage

...and many more. Topics range from "soft skills" like general career advice out to more technical topics like single page applications and Doctrine+Symfony. You can find out more about the schedule and the conference on the event's main page and even order your tickets for this great event!

tagged: symfony conference symfonylovesphpusa18 schedule announcement

Link: https://symfony.com/blog/the-schedule-for-symfony-loves-php-usa-2018-conference-is-released

Tomas Votruba:
Painful Experience over Solutions: Extend Configuration in Easy Admin Bundle
Aug 21, 2018 @ 10:15:19

In a new post to his site Tomas Votruba talks about the benefits of writing SOLID code and uses a more real-world example rather than talking about SOLID in theory.

Use SOLID to write Clean Code... Are you tired of theoretical post about how to do achieve some therm? So am I. Instead, let's dive into real problems I came across while coding and let the code speak the theory between lines.

Today we try to add own config option to YAML of Easy Admin Bundle (without pull-request to the package).

In his example, he works with a training platform he's creating for use by the Pehapkari community that makes use of the EasyAdminBundle. He starts off with what he's trying to accomplish ("the need"): being able to change only certain pieces of information. He then walks through the process he followed to customize the form and "getting creative" to be able to add items to the form without having to add each individually. He walks about his "wandering" through the code to look for a solution and, ultimately, how he found the answer using another configuration file.

tagged: solid design configuration easyadminbundle symfony tutorial

Link: https://www.tomasvotruba.cz/blog/2018/08/20/painful-experience-over-solutions-extend-configuratin-in-easy-admin-bundle-with-collector/

Titouan Galopin:
How to build a scalable Symfony application on Kubernetes
Aug 20, 2018 @ 11:23:17

Titouan Galopin has written up a post to his Medium.com site showing a method he's created to set up a scalable Symfony application on Kubernetes, a container management system.

Modern web applications are complex. The expectations of your users regarding your application are constantly increasing: nowadays, an application needs to be fast, convenient, easy to use and beautiful.

Meeting these demands can become another difficulty in the path towards creating a great product. [...] To ease this new difficulty and decrease the time spent on creating and maintaining these expected features, a modern application usually leverages many different components, from content delivery networks (CDN) to full text search services and load balancers.

[...] When you use such infrastructure, being able to interact easily with all its components from within your application is critical. This is where Kubernetes and Symfony are working together to help you achieve incredible results, extremely quickly.

The post starts by introducing some of the basics around Kubernetes for those not familiar with it and the platform they'll be using: Google Cloud Platform. He then talks some about using Symfony in a Kubernetes environment and the role that scalability plays in how you write your code. He makes a few suggestions to make it easier including:

  • Use Flysystem to store your application files in the managed file store
  • Configure Doctrine to use the provided SQL service
  • Use Redis for your cache and your sessions

There's a description for each item in the list, configuration examples where they'd help illustrate, and some links out to other resources for more information.

tagged: symfony tutorial kubernetes scaleable application docker container

Link: https://medium.com/@galopintitouan/how-to-build-a-scalable-symfony-application-on-kubernetes-30f23bf304e