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

Tomas Votruba:
Do you Autowire Services in Symfony? You can Autowire Parameters Too
Nov 07, 2018 @ 11:20:14

In a new post to his site Tomas Votruba looks at autowiring Symfony services and parameters to make it even easier to integrate services into your application.

I love how Symfony caught up late autowiring integration in since Symfony 2.8. Then set a trend in Symfony 3.3 with service autoregistration.

That opens new possibilities to almost config-less registration, doesn't it?

He first looks at some of the "old" configuration handling, defining the services manually in the YAML configuration along with their arguments. He shows how this evolves with the addition of autowiring and autodiscovery, minus the parameters. He continues on to show how to integrate parameter handling into the services configuration via the bind option. He also shows how to improve this and use autowired parameters and call them directly in the constructor of your class and let the DI container do the rest.

tagged: symfony autowire service parameter tutorial example yaml configuration

Link: https://www.tomasvotruba.cz/blog/2018/11/05/do-you-autowire-services-in-symfony-you-can-autowire-parameters-too/

Three Devs & A Maybe Podcast:
The Symfony Ecosystem with Nicolas Grekas
Nov 02, 2018 @ 14:57:43

The Three Devs & A Maybe podcast, hosted by Michael Budd, Fraser Hart, Lewis Cains* and Edd Mann, has released their latest episode where they talk with guest Nicolas Grekas about the Symfony ecosystem.

In this week’s episode Edd and guest co-host Neal Brooks chat to Nicolas Grekas about all things Symfony. We start off discussion with how he got interested in programming, his introduction to Symfony, and his journey to now working on the code-base almost daily. This leads us on to talk about how he helped build the performance profiler Blackfire, and the importance of quantitative measurements whilst making performance improvements.

From here we highlight managing pull requests, the social factors when leading open-source projects and Symfony’s continuous migration path. Finally, we touch upon the recently released Messenger component and upcoming Symfony Contracts initiative.

You can listen to this latest episode either using the in-page audio player or by downloading the mp3 directory for listening offline. If you enjoy the show, be sure to follow them on Twitter and subscribe to their feed to be notified when new shows are released.

tagged: threedevsmaybe podcast episode symfony ecosystem nicolasgrekas

Link: https://threedevsandamaybe.com/the-symfony-ecosystem-with-nicolas-grekas/

TutsPlus.com:
How to Use the Symfony Event Dispatcher for PHP
Oct 29, 2018 @ 13:40:03

The TutsPlus.com site has posted another tutorial where they go in-depth with one of the components of the Symfony framework. In this new tutorial they cover the Symfony Event Dispatcher component including its basic use via events and subscribers.

Today, we're going to learn how to use the Symfony event dispatcher component, which allows you to create events and listeners in your PHP applications. Thus, different components of your application can talk to each other with loosely coupled code.

[...] The event dispatcher component provides three elements that you could build your app architecture around: event, listener, and dispatcher. The whole system is orchestrated by the dispatcher class, which raises events at appropriate points in an application and calls listeners associated with those events.

The tutorial starts with the command you'll need to get the dispatcher installed and examples of:

  • creating events
  • dispatching the events to subscribers
  • listening for the events

The tutorial then covers subscribers, reusable listeners that can be added to the list for handling when an event fires. Code examples are included for all topics.

tagged: symfony event dispatcher component tutorial introduction

Link: https://code.tutsplus.com/tutorials/handling-events-in-your-php-applications-using-the-symfony-eventdispatcher-component--cms-31328

Alex Makdessi:
Diving into Symfony's DependencyInjection - Part 1: First steps with the container
Oct 10, 2018 @ 11:53:34

Alex Makdessi has a post on his Medium.com site kicking off a series of posts taking a deeper look into the Symfony DependencyInjection component. In this first part of the series he takes some of the "first steps" with the container.

this article, we’re going to dive into Symfony’s dependency injection component. We will use it from scratch, out of the Symfony framework, with the minimum of external dependencies. You can code along with me while reading this article, each steps will be detailed so you can easily follow.

He starts off the tutorial by creating a new project and including the DependencyInjection (DI) component via Composer (as well as symfony/var-dumper for debugging). He then starts in on the code showing how to make a ContainerBuilder instance to hold the object instance for reuse. With the container created, we now need something to use it. He creates a basic piece of functionality that works similar to the "voters" included with Symfony's security component to determine if a user has a certain role. He first creates this as a stand-alone tool but then refactors it so that the access manager and post voter objects are pulled from the dependency injection container rather than made manually.

tagged: symfony depdendencyinjection part1 series firststeps voter tutorial

Link: https://medium.com/manomano-tech/diving-into-symfonys-dependencyinjection-part-1-first-steps-with-the-container-2fad0593c052

Symfony Blog:
The SymfonyLive Paris 2019 website is online!
Oct 09, 2018 @ 11:09:32

On the Symfony blog they've posted an announcement about the launch of the SymfonyLive Paris 2019 website, the Symfony-focused event happening March 28th and 29th in Paris, France.

Last week, we announced the dates of the next edition of the French SymfonyLive conference, March 28-29. Today we're very pleased to announce that the conference website is now online! Early bird registration is open as well as the >Call For Papers. You can start submit your talk proposals (in French) for the conference. CFP will be open until December 17th (included). We encourage you to submit several talk proposals to increase your chances of selection.

[...] Early bird registration is open until December 17th (included). You can register for the 2 days of conference on March 28-29 for 239€ (breakfast, lunch, food for both days and your free conference t-shirt are included)! We organize pre-conference workshops on March 26-27, the workshops' topics will be announced soon, stay tuned!

If you're curious to see what kind of content has been presented in the past at SymfonyLive conferences, check out their YouTube channel. Otherwise, start getting those ideas submitted!

tagged: symfonyliveparis19 website release symfony conference callforpapers earlybird

Link: https://symfony.com/blog/the-symfonylive-paris-2019-website-is-online

Three Devs & A Maybe Podcast:
Running Symfony on AWS Lambda with Neal Brooks
Oct 08, 2018 @ 13:14:16

The Three Devs & A Maybe podcast, hosted by Michael Budd, Fraser Hart, Lewis Cains and Edd Mann, has posted their latest episode: Running Symfony on AWS Lambda with Neal Brooks

In this weeks episode we are lucky to be joined by Neal Brooks, a fellow developer of Edd’s at MyBuilder. We start off by discussing how he got into programming, QBasic and video driver shenanigans. From here, we move on to introduce his SymfonyLive London talk ‘Running Symfony on AWS Lambda’. We highlight what drew him to Lambda, and the new tooling that is making it easier to run PHP and frameworks (such as Symfony) on it. This leads us to cover his demo application, and explore handling assets using S3, database migrations and AWS resources using CloudFormation. Finally, we debate using catch-all gateway endpoints vs. dedicated gateway endpoints and Lambda performance.

Other topics mentioned include using a CDN with Symfony, the dittto/serverless-s3-assets library and the Mince Pie Challenge. You can listen to this latest episode either using the in-page audio player or by downloading the mp3 of the show directly. If you enjoy the episode, be sure to subscribe to their feed and follow them on Twitter for updates when new shows are released.

tagged: threedevsmaybe podcast episode symfony awslambda nealbrooks

Link: https://threedevsandamaybe.com/running-symfony-on-aws-lambda-with-neal-brooks/

Symfony Blog:
New in Symfony 4.2
Oct 05, 2018 @ 12:06:50

Over the past several weeks the Symfony project blog has released a series of posts detailing new features in the 4.2 release of the framework. Here's the current listing of those posts:

Each post includes a summary of the changes or additions and some example code and configuration showing it in use.

tagged: symfony framework feature component update addition list

Link: https://symfony.com/blog/

Symfony Blog:
Introducing Symfony Panther: a Browser Testing and Web Scraping Library for PHP
Sep 26, 2018 @ 12:24:02

Earlier this month, the Symfony blog made an announcement about a new browser testing and web scraping tool that's been released under the Symfony umbrella: Panther.

Since the very first version of Symfony 2, the framework provides a suite of convenient tools to create functional tests. They use the BrowserKit and DomCrawler components to simulate a web browser with a developer-friendly API.

The post starts with a "refresh" of the current WebTestCase helper functionality to create these functional tests. They also include an example of a repository class that stores/retrieves the news and a matching controller to handle the requests (and Twig templates for output). They then create a test using the WebTestCase functionality to get the index and ensure that some of the content is correct.

The tutorial then takes this same scenario and applies tests using the new Panther functionality. Where the WebTestCase uses a simulated browser internal to the framework, Panther uses an actual browser to run is tests using the Facebook PHP WebDriver library. They show the slight updates that would need to be made to the current test and the resulting output.

The tutorial goes on to provide other examples of tests for API requests and Javascript functionality for a Vue.js frontend. It wraps up mentioning some of the additional functionality Panther includes such as the ability to take screenshots and injecting Javascript into the pre-rendered page.

tagged: panther symfony tutorial introduction testing functional library

Link: https://symfony.com/blog/introducing-symfony-panther-a-browser-testing-and-web-scrapping-library-for-php#comment-form

Twilio Blog:
How to Send SMS Reminders from PHP Symfony Applications
Sep 25, 2018 @ 09:42:18

On the Twilio blog today Sylvan Ash has written up a tutorial showing how to send SMS reminders from a Symfony application as reminders of certain events.

If you have a booking system, making appointments such as massage or other therapist bookings, dental or medical appointments, etc., you’d probably like to remind the client about the booking they made on the day of the appointment. In some cases, you might also want to remind the person offering the service. In this tutorial, you'll learn how to send SMS reminders to clients of their upcoming massage appointments, at a designated time before the appointment, in a Symfony project using Twilio's SMS service.

The tutorial starts with a brief description of the setup and uses Composer to create a new Symfony project (the "Appointments" application). It then moves on to the models, defining the structure for the User and Appointment entities. It also shows how to make use of the seeding functionality to create several default users. Next up comes the Twilio integration: installing the SDK via Composer, defining the configuration and adding the client as a service.

With all of that set up, the final pieces are shown: the command to send the SMS messages via the Twilio service and the cron job to run it once a day at midnight.

tagged: symfony tutorial send sms application reminder appointment

Link: https://www.twilio.com/blog/sending-sms-reminders-with-symfony-php-framework

Jolicode.com:
How to Mix Security and Form with Symfony
Sep 21, 2018 @ 12: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