How to use Symfony DomCrawler with examples

The Symfony DomCrawler component is a powerful tool within the Symfony framework for web scraping and HTML/XML parsing. It provides a convenient and intuitive API for traversing and manipulating HTML or XML documents, making extracting specific elements, attributes, and text from web pages easier.

How to fix "You have a new message" iOS notification

In the last few days, I get "You have a new message" Gmail notifications on my iPhone instead of the normal notification with the subject and part of the message itself.

It's quite an annoying issue, given the fact that I haven't changed my notifications settings.

How to use Symfony process component with examples

To use Symfony process, you need first to install the component:

$ composer require symfony/process

How to modify image EXIF metadata - Date Created / Date Modified [Command line tool]

To modify image EXIF metadata - Date Created / Date Modified you can use ExifTool with the following command:

exiftool -AllDates='2021:11:11 13:25:23' my_image.jpg

Where 2021:11:11 13:25:23 is the desired date and my_image.jpg is the filename of the image.

Note that this is a command line tool that has no graphical interface.

Full Exiftool installation guide

You can find step by step tutorial below.

How to generate app secret in Symfony

To generate Symfony app secret (APP_SECRET) env variable, you can use this hash function

$ date | md5

This takes the current date and hashes it with the md5 function.

What's new in PHP 9

PHP 9 will be the next major release of the PHP language.

The release date is still unknown, but we have hints about what's new. By looking into the PHP Wiki RFC section, we can get clues about what is coming next.

In this article, we'll cover the approved/implemented RFC (Request for Comments) and keep it updated with the latest information about PHP 9.

How to run ElasticSearch queries with PHP and cURL example

In the realm of modern data handling, Elasticsearch has emerged as a powerhouse, offering rapid data search and analysis.

As a PHP developer, integrating this robust search engine into your projects can elevate your data operations to new heights. In this article, we'll illustrate a concise example of how to create an index, create a document, get a document, and search for documents using PHP's cURL library.

The following examples will empower you to efficiently store, retrieve, and manipulate data through Elasticsearch's RESTful API, all within the familiar PHP environment.

Symfony vs Laravel Performance Benchmark

I've decided to test the performance of two popular PHP frameworks - Laravel and Symfony. The results surprised me.

The performance test which I've conducted is quite simple. I've created two projects in Symfony and Laravel with only one page, no database queries, no API calls, and no complex calculations, just one simple page. Then I ran HTTP stress tests using a benchmarking tool against both setups and the results are surprising.

You can check both projects on my GitHub - Symfony / Laravel.

Symfony version: 5.4

Laravel version: 10.10

Did you know that Laravel uses a lot of Symfony components under the hood?

Symfony is known for making really good components used across the whole PHP ecosystem in numerous packages. Most of the Symfony components can be used as a standalone package without the need for Symfony itself, which is quite handy.

For example, the laravel/framework packages uses 11 Symfony components (at the time of writing this post), some of which are symfony/routing, symfony/mailer, symfony/http-foundation etc.

Let's start with the fun part.

How to get all indices in ElasticSearch with curl command?

To get all indices in ElasticSearch with curl, you can use the following command:

$ curl localhost:9200/_cat/indices

which outputs

$ curl localhost:9200/_cat/indices
yellow open test-index-yoan                 5ChC9F9ZSGSRmooDAIrd9A 1 1 0  0   208b   208b
yellow open my-index-000001                 Be3surqXQzy8_EVW9k1VZA 1 1 0  0   208b   208b

mod_php vs php-fpm Performance Benchmark [Surprising Results]

Have you ever wondered if Apache mod-php is faster than php-fpm with Nginx? I surely did.

Each time this question arises, I do a quick research, and I cannot seem to find a definitive answer. It seems that the recommended way to run PHP websites nowadays is to use php-fpm with Nginx, but is that the best method? Some articles state that php-fpm is 300% faster than mod-php, other articles state that mod-php is faster, and so on.

This is why I've decided to conduct my own tests and performance benchmark and settle this debate once and for all.

The result surprised me.