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

Cees-Jan Kiewiet:
Extending ReactPHP's Child Processes Part Two
Nov 29, 2017 @ 11:42:29

Continuing on from his first part of the series Cees-Jan Kiewiet has posted part two of his series covering the extension of ReactPHP's child processes.

react/child-process is very flexible and can work a lot of ways but sometimes you don't want to be bothered with the details of how it works and just want a simpler API to do that.

He mentions his wyrihaximus/react-child-process-pool package that makes working with the pool of processes easier and covers some of the "under the covers" handling behind it. He then shows an example of it in use, creating a pool that executes database queries via Doctrine's DBAL functionality to select the number of users from the users table. He then refactors it a bit using the wyrihaximus/react-child-process-closure functionality to make the child processing of a closure simpler.

tagged: reactphp child process series part2 tutorial

Link: https://blog.wyrihaximus.net/2017/11/extending-react-child-process-part-two/

Sergey Zhuk:
Building ReactPHP Memcached Client: Unit-Testing Promises
Nov 21, 2017 @ 11:43:32

Sergey Zhuk has posted the latest part of his "Building a ReactPHP Memcache client" series to his site today. In this latest article, part four of the series, he focuses on unit testing the client as he's developed it so far.

This is the last article from the series about building from scratch a streaming Memcached PHP client for ReactPHP ecosystem. The library is already released and published, you can find it on GitHub. In the previous article, we have completely finished with the source code for async Memcached ReactPHP client. And now it’s time to start testing it.

He then walks through some of the steps to create the tests for the client, made a little more difficult by its asynchronous handling. He shows how to use Mockery to create tests that evaluate the results of the promises from the client, starting with a simple check on the return of a version call. The post goes on to show testing for other parts of the client and includes all of the code and commands you'll need to execute them in your own environment.

tagged: reactphp memcached client asynchronous tutorial series part4

Link: http://sergeyzhuk.me/2017/11/20/memcached-reactphp-p4/

Michael Dyrynda:
Uploading files to Amazon S3 from the browser - Part One
Nov 06, 2017 @ 11:58:34

Michael Dyrynda has a tutorial posted to his site starting off a new series showing how to create the functionality in your application to upload files to Amazon S3 from the browser. The tutorial is designed for those that don't already have something in their framework that allows for this upload handling.

I recently took on a freelance project that involved having to upload media files. This is a trivially simple task to accomplish if you're using something like Laravel, using out-of-the-box support for S3 storage.

In this particular case, however, I was dealing with files potentially multiple gigabytes in size. Although a simpler to implement, I didn't want to have to have users of the site upload the file to my application - and thus server - before having my server re-upload the file to S3.

In his case, he needed something that would allow for the upload of very large files without having to pass it through the backend server to get there. He starts by walking you through the setup on the S3 side, creating an IAM policy for the upload and a form that points to the instance. The form includes a "key" value that contains the filename for the end result. He also shows some of the other options that can be included like the policy to use a redirect location and a signature to verify the upload. He then shows the code required to make it work, creating an upload route and a main form page that generates the signature and policy information for the form based on configuration options.

tagged: amazon s3 upload tutorial part1 series direct post

Link: https://dyrynda.com.au/blog/uploading-files-to-amazon-s3-from-the-browser-part-one

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/

Asmir Mustafic:
Modular Application Architecture - Intro
Nov 02, 2017 @ 13:56:23

Asmir Mustafic has kicked off a new series on his site with an introduction to modular application architectures. In the series he will work through the creation and management of modular applications as inspired by a session he attended in 2011.

When developing a software, one of the most common steps is taking care that the resulting application is extensible and modular.

Let's suppose we have our application or library. If we see it from outside, often it looks as a single thing. [...] As the application grows we can continue adding components... but this comes with a price. Components often knows too much of our application and there is a delicate equilibrium of dependencies between them and our application. When not handled carefully, a small change in one component might require changes in many other.

As a rule of thumb, I personally try to follow as much as possible the Acyclic dependencies principle Another way to allow extensibility but keeping the application "clean" is to introduce modules.

He starts by talking about modules and the major part they'll play in the overall architecture. He explains why modules are so key to the overall structure and what kind of advantages they bring along with their use. He spends the remainder of the post looking at some of the main challenges they'll face including the file/directory structure definitions, module registration methods and the configuration of each of the modules.

tagged: modular application architecture introduction tutorial series part1

Link: https://www.goetas.com/blog/modular-application-architecture-intro/

Asmir Mustafic:
How do I deploy my Symfony API - Part 5 - Conclusion
Oct 31, 2017 @ 12:47:25

Asmir Mustafic has finished out his series showing his method for the deployment of Symfony applications with part five sharing some additional improvements that could be made to the system created in the four previous parts.

This is the fifth post from a series of posts that described the whole deploy process from development to production of a Symfony API. This series of blog posts had the aim to show a possible approach to build a continuous integration and continuous delivery pipeline.

The continuous integration and continuous delivery process reduces bugs and makes the development simper. [...] As always happen in software development, solutions are not perfect. There is always room for improvement. Here are few examples of what could have be done better. Obviously can be done better and this are not all the possible improvements that can be done on the system.

In the remainder of the article he includes changes that could be made to the:

  • migration execution, allowing for it to be done between deployments
  • performing health checks of the API
  • Docker container placement
  • putting PHP and Nginx into the same container
  • "node draining" (removing a node from a cluster)

He wraps up the post with a mention of a tool, Kubernetes, that can help to make the configuration and management of your containers easier.

tagged: deploy symfony api tutorial series part5 conclusion

Link: https://www.goetas.com/blog/how-do-i-deploy-my-symfony-api-part-5-conclusion/

Sergey Zhuk:
Building ReactPHP Memached Client: Errors And Connection Handling
Oct 27, 2017 @ 09:21:56

Sergey Zhuk has posted the second part of his series covering the creation of a ReactPHP-based memcached client for asynchronous cache handling. In part one he set up some of the basic structure of the client and got it to a working state. In this latest part he expands on that base and improved the error and connection handling to make it more robust.

In the previous article, we have created a simple streaming Memcached client for ReactPHP ecosystem. It can connect to Memcached server, execute commands and asynchronously return results. In this article we are going to implement some improvements: connection handling [and] errors handling.

He then goes through and makes changes to allow for correct handling of the connection closing where it can either be closed by an option you specify or a forced close from the server. On the error handling side he shows how to handle invalid commands (throwing a WrongCommandException) and a failed command, such as when the value couldn't be stored for one reason or another.

tagged: reactphp memcached client async error connection handling series part2

Link: http://seregazhuk.github.io/2017/10/14/memcached-reactphp-p2/

Asmir Mustafic:
How do I deploy my Symfony API - Part 4 - Deploy
Oct 11, 2017 @ 10:23:12

Asmir Mustafic has posted the next part of his series covering the deployment of Symfony applications. In this latest article (part four) he focuses on some of the final steps of the deployment process.

This is the forth post from a series of posts that will describe the whole deploy process from development to production. The first article is available here, the second here and the third here.

After covering the steps 1-3 and having prepared our infrastructure, we can see how to deploy our application to production. Almost the same approach can be used to deploy not only to production but also to test environments.

He starts with the workflow for the deployment process, creating a flow where the "git push" should trigger other actions based on the branch pushed. Then CircleCI will fire off a series of jobs to handle environment setup tasks, connecting to a VPN and deploying the code. This includes a bit of preparation, credential handling and the Docker setup and push. Each step along the way also includes all of the YAML configurations you might need to replicate the deployment.

tagged: symfony api deployment part4 series docker configuration example

Link: https://www.goetas.com/blog/how-do-i-deploy-my-symfony-api-part-4-deploy/

Build a React App With a Laravel Back End: Part 2, React
Oct 11, 2017 @ 09:43:49

The TutsPlus.com site has posted the second part of their series covering the creation of a React application with a Laravel backend. In part one of the series they started in on some of the setup for the application. In part two continues down that path and shows how to set up React and integrate it with the Laravel backend.

In the previous tutorial, we developed a Laravel application that responds to API calls. We created routes, a controller, and a model for the simple product listing application. Since it was the controller's job to return a response to the HTTP requests, the view section was entirely skipped.

[...] In this tutorial, we will be shifting our focus towards the front end. The first half of the tutorial is about setting up React in a Laravel environment. I will also introduce you to Laravel Mix (supported by Laravel 5.4 and later), which is an API for compiling assets. In the second half of the tutorial, we will start building a React application from scratch.

The tutorial walks through the the use of the Laravel artisan command to help with some of the setup tasks and the creation of some of the initial templates and Javascript files. Then it starts in on the application itself including the display of product data and functionality to add a new project.

tagged: react application laravel backend tutorial series part2

Link: https://code.tutsplus.com/tutorials/build-a-react-app-with-laravel-backend-part-2-react--cms-29443

Tomas Votruba:
EasyCodingStandard and PHPStan meet 3 Symfony E-Commerce Projects
Oct 09, 2017 @ 12:55:22

Tomas Votruba has a post to his site showing you how to combine EasyCodingStandard and PHPStan on a Symfony-based ecommerce project. This is the second part of a series comparing the code of three popular Symfony ecommerce packages (part one is here).

In the last post, we looked at the static analysis of 3 Symfony E-Commerce projects.

Lines of code, Duplicated code, Cyclomatic complexity or Method length. These metrics are very rarely used in practise (even though there is a sniff for that).

Today, I am going to show you how you can check them with tools that can help you keep your code better on daily basis - EasyCodingStandard and PHPStan.

He's provided the code he used to analyze the packages - ShopSys, Sylius and Spryker. He goes on to talk about some of the tool choices and the resulting code violations from the PSR-2 checks. He also covers some of the "cleaners" that helped to remove some dead code and the violations uncovered by PHPStan.

tagged: easycodingstandard phpstan ecommerce results series part2

Link: https://www.tomasvotruba.cz/blog/2017/10/02/easy-coding-standard-and-phpstan-meet-3-symfony-ecommerce-projects/