This is the second post about Swoole and it contains code samples that take advantage of Swoole asynchronous functions and coroutines. The first post can be found here. HTTP Requests Asynchronous 1: We put each request in a separate coroutine and pass them a channel through which they will pass to us the results of…
Tag: PHP
PHP asynchronous programming with Swoole: Part 1
This first part will provide some basics on working with Swoole and it is meant to work as an introduction to the code samples we will include in the second part. Slowly but steadily, mostly in the last 5-6 years, PHP is making steps to the direction of asynchronous programming. Although ReactPHP was showing the…
Design patterns in Action: Flyweight and Enumerated types
Flyweight pattern is not a pattern that you will come across very often in web applications. Most web applications are just serving incoming HTTP requests, a task that lasts just a few milliseconds. So, memory usage is not really a consideration for their developers. However, there is one area where you can see this pattern…
Web Frameworks: The Laravel bootstrap process
Every developer who respects himself should, sooner or later, understand the tools he/she is working with work. And frameworks are not an exception. For those who don’t have the time to delve into the Laravel internals, here is a list of the main actions that take place every time Laravel is called (based on version…
Web Frameworks: The Laravel DI container
This is an overview about Laravel’s DI container ( Illuminate\Container\Container ) and its functionality. It is interesting to have a look since the logic behind most of the DI containers is more or less the same (not to be surprised. After all, the goal is the same, too.) (a) It is a singleton. There can…
Design Patterns in Action: Decorator and SPL Iterators in AWS S3
My purpose here is to talk about the decorator pattern in SPL iterators. But since many people are not aware of how much the iterators are really used, I would also like to point out one of their use cases in real life. So, my starting point will be AWS Simple Storage Service (S3). For…
Design patterns in action: Builder and Symfony Finder
The Symfony Finder ( Symfony\Component\Finder ) is a component that, according to its documentation, can be used to “build rules to find files and directories”. This functionality includes a numder of optional parameters that can be used to construct the Finder object based on what files or directories we are looking for. The Finder uses…
PHP sessions under the microscope: Part 2
Security Considerations Sessions can be attacked. That’s a fact. And there are many ways to attack them. Three of the most common ways to do this are “session fixation” , “session hijacking” and “session flooding”. In simple words, session fixation is about tricking someone to use a session ID that does not belong to him/her….
PHP sessions under the microscope: Part 1
I will start by saying a few things for the purpose of sessions. As we know, the main web protocol, which most communications are based on, is HTTP. By nature, HTTP is a stateless protocol. Requests are not associated to each other and, because of this, they should contain enough information on their own to…
PHP Reflection: real-life use cases
Reflection is one of these language features that most developer may have never used and may never use in their lifetime. And that’s fine! Reflection is there to handle some very specialized cases. It’s not there for fun. But I am sure that many of you may wonder how often this feature is being used…