php[architect] logo

Want to check out an issue? Sign up to receive a special offer.

Running Parallel

October 2020

While we think of our scripts running for one request at a time, PHP web applications handle multiple, simultaneous requests at a time. In this issue, we look at asynchronous programming using Swoole, handling serverless file uploads, implementing security headers, dealing with race conditions, and more.

Build An All-In-One Application Server Using Swoole

By Demin Yin

In recent years, more and more PHP developers are interested in asynchronous frameworks, like Swoole. However, Swoole brings more than asynchronous programming to PHP; there are a few mind-blowing features in Swoole that many developers are not yet aware of. This article discusses how to use Swoole to build an application server to serve web requests, handle cron jobs, and process job queues without relying on any third-party applications or software.

More Than Asynchronous I/O, Introduction To Swoole PHP

By Bruce Dou

Swoole PHP is a coroutine based asynchronous network application framework. It is a PHP extension that extends PHP core and utilizes more power provided by Linux OS. Unlike the callback style single thread asynchronous I/O provided by the other networking libraries like Node.js, Swoole PHP has multiple asynchronous I/O threads and native coroutines to manage the execution of concurrent tasks. Other than asynchronous I/O and coroutine, we can also use the Linux system API and interface exposed by Swoole PHP, such as process management, system signals handling, timer and scheduler, poll and epoll I/O, memory management, etc.

Serverless File Uploading

By Volodymyr Khvorostiankin

The Internet as we know it is diverse, interactive, and personalized. Users of many resources strive to make their page or their channel unique. How can I do that? By uploading custom content. It can be virtually any file—an avatar, cover images, video, documents, you name it! Our task as professional developers is to ensure that users can share such content. Still, we also have to think about business requirements, minimize infrastructure costs, and increase the project’s resiliency. So let’s look at the ways to upload files using PHP, their advantages and disadvantages.

PHP Puzzles: Improved Directions

By Sherri Wheeler

In our last issue, we simulated population growth—a component of many popular games. In this article, we look at pruning redundant items from a list of directions.

Education Station: Race Conditions and Dead Locks

By Chris Tankersley

Despite PHP shifting more and more toward preferring Object-Oriented Programming, at its heart, PHP is a procedural language. All of the code is executed one line at a time, in the order that the parser receives it. To my mind, one of PHP’s strengths is blending a versatile object model along with procedural programming. Web applications can surface race conditions and dead locks more frequently, like any other program with potentially multiple concurrent users, as people update or work with the same resources.

The Workshop: PHP Development with Homestead in WSL

By Joe Ferguson

We’ve spent the past two months talking about Windows Subsystem for Linux (WSL) in Windows 10 and how to customize it to serve as a PHP development environment. While functional, our environment lacked a fair bit of polish. In the nearly four years that I’ve been working on and maintaining Laravel Homestead, I’ve spent much of that time adding functionality and polish to the Laravel focused Vagrant development environment. Homestead is a fantastic PHP development environment that provides many tools PHP developers have come to expect: NGINX and Apache support, easy access to multiple PHP versions, MySQL and PostgreSQL databases, and an easy “reset” method in case something goes wrong you can quickly get back to a known state. This month we’re going to explore the ongoing Homestead development to bring some of the polish and ease of use from Homestead to WSL.

Sustainable PHP: Refactor to Competitive Advantage

By Edward Barnard

Technical debt is always, and continuously, a challenge. Needs change. This month we’re looking at an approach for being continually prepared for change—refactoring, with unit tests in place.

Security Corner: Configurable Security

By Eric Mann

Having a tool like Mozilla’s Observatory scan the health of your site is useless if you lack the tools to properly secure it and pass the inspections in the first place. You can set most of the required settings directly in the source of your application.

Community Corner: Larabelles

By Eric Van Johnson

“If you are looking for a development community and when you look around, if you don’t find one, congratulations, you are now the organizer of your new development community.” These were the (paraphrased) wise words spoken by one Cal Evans ( @calevans). This advice inspired John Congdon to reboot my local PHP User Group in San Diego. It’s also the action that was taken by this month’s interviewee, Zuzana Kunckova, when she looked around for a development community she wanted to belong to. Zuzana’s twitter announcement was straightforward and said it all.

finally{}: Async Life

By Beth Tucker Long

Our day-to-day used to be full of needing to get to physical locations in person at specific times, but just like programming, we are becoming more and more asynchronous.

Leave a comment

Use the form below to leave a comment: