Amazing PHP
9.94K subscribers
11 photos
84 links
Welcome to the Amazing PHP Channel! Here you can find a lot of interesting articles/news about PHP, frameworks, tools and development.

Support the channel: https://www.paypal.com/donate?hosted_button_id=FAYP5QJH5LVRL
Download Telegram
Profiling PHP in production at scale
At Wikipedia, we built an efficient sampling profiler for PHP, and use it to instrument live requests. The trace logs and flame graphs are powered by a simple setup that involves only free open-source software, and runs at low infrastructure cost.
​​It is an argument, not a trojan horse!
Let's talk about something cool: trojan horse parameters. This is how I call this fancy technique which many of us, developers, might have used (or still doing). Ok, so what is it?
​​Happy New 2021 Year Everyone! πŸ₯‚πŸŽ‰
Object properties and immutability
There has been much discussion in recent weeks in PHP circles about how to make objects more immutable. There have been a number of proposals made either formally or informally that relate to object property access, all aimed at making objects safer through restricting write access in some way.
Mastering binary and bitwise in PHP
I recently caught myself working on different projects that required me to rely heavily on bitwise operations in PHP. From reading binary files to emulating processors, this is a very useful knowledge to have and a very cool one too.
​​Scaling PHP FPM based on utilization demand on Kubernetes
Ever since I've migrated to Kubernetes I've been working on a Matomo Helm chart. Part of that Helm chart is having autoscale it on how busy PHP FPM is, a.k.a. the percentage of busy workers.
Object properties and immutability
There has been much discussion in recent weeks in PHP circles about how to make objects more immutable. There have been a number of proposals made either formally or informally that relate to object property access, all aimed at making objects safer through restricting write access in some way.
Mastering binary and bitwise in PHP
I recently caught myself working on different projects that required me to rely heavily on bitwise operations in PHP. From reading binary files to emulating processors, this is a very useful knowledge to have and a very cool one too.
Building an Object Model: No setters allowed
If you are using an object relational mapper or any other database abstraction technology that converts rows to objects, then you will probably use getter/setter methods or properties (C#) to encapsulate object properties.
PHP Curl Security Hardening
Curl is powerful and feature-rich command line tool and a library for data transferring with URLs, with support for several protocols including HTTP and HTTPS, among dozens of others. It supports modern features such as QUIC and TLS 1.3, and it comes with several customization options.
The Definitive PHP 5.6, 7.0, 7.1, 7.2, 7.3, 7.4, and 8.0 Benchmarks (2021)
Much like for humanity (and Kinsta), 2020 has been a noteworthy year for PHP. The much-anticipated PHP 8 released on November 26, 2020, bringing many breaking changes from its previous versions. You can catch up on all the juicy PHP 8 features in our in-depth post.
Amazing PHP pinned Deleted message
​​Symfony and Hexagonal Architecture
I have been working on many Symfony projects in my career and one of the most common problems where customers call our company is that their software is blocked in the old framework version, or they are not maintainable because it costs a lot to find and fix bugs.
Preventing Dependency Confusion in PHP with Composer
The problem boils down to companies referencing internal packages by name, e.g. "my-internal-package" and an attacker then publishing a package by the same name "my-internal-package" with a higher version number on the central registry / package repository for that language (for PHP that would be packagist.org). The companies then installed and ran these malicious packages instead of their internal packages because their package manager chose the higher version number from the default package repository over their internal repository.
When to use empty in PHP? I’d say never
I realized that I am very strict about the use of PHPs empty function in code review. There isn’t really any reason to use it in my opinion:
Sell files online fast and easy
Want to sell e-books, PDF documents, audio/video files, or any other type of files? It is easy.
Just upload your file, get a short link, share it and make money. No monthly or hidden fees.
Testing HTTP Middleware in Laravel
Testing HTTP middleware in a Laravel app might look easy at first glance but can be surprisingly difficult to get right. There are many possible pitfalls. In this post, I want to show some of these pitfalls and what problems they can cause. Then, I will explain how I write tests for my custom middleware.
Object Oriented Done Right
Alan Kay, the inventor of the term β€œobject-oriented programming”, told a story once during a talk more than 20 years ago. You can build a dog house using only a hammer, nails, planks, and just a little bit of skill. I figure even I would be able to build it given enough time. Once you've built it you've earned the skills and know-how, and could apply it to other projects. Next, you want to build a cathedral, using the same approach with your hammer, nails, and planks. It's a 100 times larger, but you've done this before β€” right? It'll only take a little longer.
Modular Monolith: A Primer
Many years have passed since the rise of the popularity of microservice architecture and it is still one of the main topics discussed in the context of the system architecture. The popularity of cloud solutions, containerization and advanced tools supporting the development and maintenance of distributed systems (such as Kubernetes) is even more conducive to this phenomenon.
Observing what is happening in the community, companies and during conversations with programmers, it can be concluded that most of the new projects are implemented using the microservice architecture. Moreover, some legacy systems are also moving towards this approach.
Unit testing tips by examples in PHP
In these times, the benefits of writing unit tests are huge. I think that most of the recently started projects contain any unit tests. In enterprise applications with a lot of business logic, unit tests are the most important tests, because they are fast and can us instantly assure that our implementation is correct. However, I often see a problem with good tests in projects, though these tests' benefits are only huge when you have good unit tests. So in these examples, I will try to share some tips on what to do to write good unit tests.