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

Symfony Blog:
New in Symfony 4.1: Misc. improvements (Parts 1-4)
May 30, 2018 @ 13:18:05

On the Symfony project blog they've posted a series of articles covering some miscellaneous improvements made for the v4.1 release of the framework.

During the past months we've published almost 40 blog posts about the main new features of Symfony 4.1. In this article you'll find some of the other small but nice new features.

Here's the list of the posts and some of the things covered in each:

  • Part 1: CSRF without forms, visibility change in progress bar component, showing dotenv files in the profiler
  • Part 2: command to delete cache pool items, allowing custom functions in "allow_if" expressions, addition of "dd" debug helper
  • Part 3: add/remove LDAP attributes efficiently, keeping the query string after redirect, hasser accessors in PropertyInfo
  • Part 4: adding anonymous services in PHP DSL, support for extracting type from constructor, configurable PHP error log level

Check out each post for a brief summary of each change and example code/configuration showing how to make use of it.

tagged: symfony improvement v41 series part1 part2 part3 part4

Link: https://symfony.com/blog/new-in-symfony-4-1-misc-improvements-part-1

Matt Sparks:
Building a PHP Framework Series (Parts 1-4)
May 16, 2018 @ 12:50:42

On this site Matt Sparks has posted the first few parts of a series covering the creation of a custom framework. Why? Well, as he explains in part one of the series:

So with all of that being said, it begs the question: why on Earth would you want to do this?

The extremely short answer: I want to. The less short answer: A PHP framework encompasses many of the areas I want to learn more about.

The first four posts of the series are already on his site (with more to come):

Matt does a great job of laying out some of the fundamentals behind frameworks including structure, design patterns, and commonalities between frameworks. You can follow along with his progress on the project on the AnalyzePHP GitHub repositories.

tagged: build framework tutorial series part1 part2 part3 part4

Link: https://developmentmatt.com/building-a-php-framework-part-4-the-foundation/

Auth0 Blog:
Symfony Tutorial: Building a Blog (Part 3)
Mar 27, 2018 @ 11:20:06

The Auth0 blog has posted the third part of their "Building a Blog" series of tutorials showing the use of their authentication technologies coupled with a Symfony framework backend. In this latest article author Greg Holmes shows how to deploy the application created in parts one and two to Heroku.

Symfony is a PHP framework as well as a set of reusable PHP components and libraries. It uses the Model-View-Controller design pattern and can be scaled to be used in any requirement. It aims to speed up the creation and maintenance of web applications, replacing repetitive code. In this part of the series, you will learn how to deploy the blog engine that you have created in the previous parts on Heroku. The final code can be found at this repository.

He starts with a bit of catching up, briefly covering the contents of the first two articles before getting into the main content of this third. He covers some of the basics of Heroku and Travis-CI before getting into the actual deployment flow. He then helps you set up a GitHub account (used as a source for the deployment), set up a local MySQL database for testing and the installation of a few required dependencies. Next is the installation of the Heroku and Travis-CI command line tools, the configuration for each and some basic setup steps for each service.

Finally, he gets back to the Symfony application, setting up a few additional options in the Composer configuration to create a few commands. These commands are then executed as a part of the deployment process. There's also changes to the Symfony configuration files to reference the environment rather than a local path in several locations. The post ends with the setup instructions on the Auth0 side to allow handling to work from the newly deployed Heroku instance.

tagged: auth0 blog symfony tutorial series part3 deploy heroku

Link: https://auth0.com/blog/symfony-tutorial-building-a-blog-part-3/

Christoph Rumpel:
Build a newsletter chatbot in PHP - Part 3
Mar 27, 2018 @ 10:57:24

Christoph Rumpel has continued his series covering the creation of a chatbot using the Botman package in a new post to his site. The latest post, part three in the series, builds on the base created in parts one and two and integrates the bot with his project website.

In part one and two we created a Facebook Messenger chatbot that let your users subscribe to your newsletter. We stored that information in the database and sent out our first newsletter. In the last third part, we integrate this bot to a website and write our first tests.

He then walks you through the process of using the Facebook Customer Chat Plugin to integrate it into the site (using the Facebook JavaScript SDK). He includes instructions on whitelisting your domain and including the plugin into the site's source using a few custom configuration options. With the integration complete he then takes a step back and shows the creation of several tests evaluating the fallback handling and subscription conversation responses.

tagged: chatbot tutorial series part3 integrate facebook testing fallback subscribe

Link: https://christoph-rumpel.com/2018/03/build-a-newsletter-chatbot-in-php-part-3

Laravel News:
Real-time messaging with Nexmo and Laravel
Mar 05, 2018 @ 10:28:04

The Laravel News site has posted the third part of their series about the construction of helpdesk software. In this latest article they integrate Nexmo for real-time messaging using Nexmo Stitch.

Welcome back to the third and final (for now!) part of the Deskmo series. In Part 2 added support for voice calls, with text-to-speech and transcription support.

Today, we’re going to add in-app messaging using Nexmo Stitch. Stitch takes care of all of the heavy lifting for real-time chat, providing you with a websocket that you connect to and listen for events relating to your application.

The article starts by listing out some prerequisites (a Nexmo client account and the Deskmo project) as well as an installation of the Nexmo Stitch command-line client. It then walks you through the process of setting up a Nexmo user profile for each user in the helpdesk software and updating the database with this new information. It then shows how to add in-app notification messaging and linking the messages and tickets together with a conversation ID. With Stitch installed you can then create the chat interface and link the backend to the Nexmo service as a user easily sending and receiving messages.

tagged: realtime message laravel nexmo helpdesk tutorial series part3

Link: https://laravel-news.com/real-time-messaging-nexmo-laravel

Pehapkari.cz:
Domain-Driven Design - Repository
Mar 02, 2018 @ 11:46:25

The Pehapkari.cz site has continued their series on domain-driven design with their latest tutorial covering the use of a repository for handling instances and collections of objects.

We will discuss how to store and read domain objects while pretending we have an in-memory system. Simply, we will show how to implement and test repository.

The article starts with a look at collections and the reality of using them outside of an in-memory environment. It then focuses in on the idea of a repository that live in the domain layer and some of the responsibilities they have as a part of the overall system. With the basics defined the tutorial then gets into the concrete implementation of the repository and how to write effective tests to ensure its correct functionality.

tagged: domaindrivendesign series part3 repository tutorial

Link: https://pehapkari.cz/blog/2018/02/28/domain-driven-design-repository/

Pehapkari.cz:
Domain-Driven Design - Implementation
Feb 22, 2018 @ 10:15:35

The Pehapkari.cz blog has continued their series covering domain-driven design with their latest post. In this new article they focus on the implementation of the concepts they've been covering starting with the domain model.

It is great to model something and now we have reached the point where we turn the model into the code. We will implement the model, no persistence, no input, only the most important part - the domain model. The implementation will be supported by tests and we will see how easy it is to test domain objects. We will also discuss the connection to the ubiquitous language and model and practical aspect of object encapsulation.

The tutorial then starts in covering the domain model structure and includes a few things to to think about during the implementation. It talks about reading values from the object and links to the full code on GitHub (rather than fill up the post with code). The post finishes by covering testing of the model, the idea of test-driven development and how it fits in with domain-driven design.

tagged: domaindrivendesign domain model implementation series part3

Link: https://pehapkari.cz/blog/2018/02/21/domain-driven-design-implementation/

Laravel News:
Building a Vue SPA with Laravel Part 3
Feb 19, 2018 @ 11:22:08

The Laravel News site is back with the latest part in their series covering the combination of Laravel and Vue.js to create a basic application. In this latest part (part 3) they continue from the previous tutorials and show how to pull in real data versus the fake data from before.

We will continue building our Vue SPA with Laravel by showing you how to load asynchronous data before the vue-router enters a route.

We left off in Building a Vue SPA With Laravel Part 2 finishing a UsersIndex Vue component which loads users from an API asynchronously. We skimped on building a real API backed by the database and opted for fake data in the API response from Laravel’s factory() method.

If you haven’t read Part 1 and Part 2 of building a Vue SPA with Laravel, I suggest you start with those posts first and then come back. I’ll be waiting for you!

In this tutorial, we are also going to swap out our fake /users endpoint with a real one powered by a database.

They get immediately back to the code, creating a "user" table seeder to generate randomized data and adding it for execution. Next, they switch to the database side, creating the MySQL database for the user data and running the seeding to create the users. The tutorial then shows the creation of the Users controller and what the resulting JSON will look like when pulling all users. Finally, it moves out to the client side and shows how to pull in the data pre-load and push the user details into a template to be rendered.

tagged: vuejs spa singlepage application part3 series tutorial laravel

Link: https://laravel-news.com/building-vue-spa-laravel-part-3

Cees-Jan Kiewiet:
ReactPHP with RecoilPHP: Creating for/http-middleware-psr15-adapter
Feb 09, 2018 @ 11:21:13

Cees-Jan Kiewiet is back with the latest tutorial in his series covering ReactPHP and RecoilPHP. In the previous parts he introduced some of the basic concepts and set up the first bits of code combining ReactPHP and RecoilPHP. In this latest tutorial (part three) he shows how to integrate this with a PSR-15 compliant middleware to evaluate response time.

There are more uses for coroutines than just making working with promises easier. In this post we're diving into the details on how they are used by the Friends of ReactPHP in the PSR-15 Middleware adapter for react/http.

When we started discussing how middleware for react/http should work we also look at the state of PSR-15 at the time. We decided against implementing it directly because of the fully blocking nature of PSR-15, in favour of callable. Which turned into an even better decision when return type hints where added to it to PSR-15. Now I love PSR-15, and middleware in general, which is why I created for/http-middleware-psr15-adapter to bridge the gap.

He starts with the code required to create a normal PSR-15 middleware and recreating the same functionality in a ReactPHP middleware. The article then shows how to use the package he developed to transform the middleware "on the fly" to enable it to be used both as a normal PSR-15 middleware and as a ReactPHP middleware. He ends the post with a word of caution and a bit of advice about using this method of rewriting - basically that just because you can doesn't mean you should.

tagged: reactphp recoil psr15 middleware translate onthefly package tutorial part3 series

Link: https://blog.wyrihaximus.net/2018/02/reactphp-with-recoilphp-party-three-http-middleware-psr-15-adapter/

Sergey Zhuk:
Building ReactPHP Memached Client: Emitting Events
Nov 03, 2017 @ 09:44:39

Sergey Zhuk has posted the third part of his series covering the creation of a Memcached client using ReactPHP has the base and allowing for asynchronous operations. In this latest part of the series (part three) he focuses on emitting events for various actions/results in the client code.

In the previous article, we have faced with a problem: how to deal with a broken connection. Now, when the connection is closed all pending requests are rejected with the ConnectionClosedException. If we want to handle this situation we need to attach onRejected handlers to all promises because we can’t guess in advance which one will be the problem.

This [example] code already looks too complex, but also there is no way to find out if the connection was broken or we have manually close it. So, it becomes clear that we need a completely different approach.

He then shows how to make use of this event library to emit events at certain points in the client's state. He includes code examples showing how to use the emit method to throw the event focusing on handling when there's connection issues.

tagged: reactphp memcached client async emit event connection handling series part3

Link: http://sergeyzhuk.me/2017/11/03/memcached-reactphp-p3/