How to Install Specific Version of Package Using Composer

Composer is a package manager for the PHP programming language. It allows you to install or update packages, manage their dependencies, and many other things. By default, Composer installs the latest stable version of a selected package. However, you can install any exact version of a package you need. In this short article, I will … Read more

How to Calculate Execution Time in PHP

There are a lot of cases when you might need to measure code execution time. For example, you want to speed up your application and need to find the slowest part or benchmark several approaches to do some task. In this article, I will show you multiple ways to measure execution time in PHP and … Read more

How to Rename Table in Laravel

Laravel has a migration mechanism for creating and changing database tables. If you want to create a new table, just create a migration and call the Schema::create() method. When you want to add or remove columns or indexes just call the Schema::table() method. But sometimes you may want to rename table. For example, you have … Read more

How to Run Raw SQL Query in Laravel

Laravel uses Eloquent to interact with the database. With it, you can perform quite complex queries. But sometimes you need to use database features that are not supported by Eloquent. In such cases, you can execute a SQL query. In Laravel, you can execute a simple SQL query and get the result as an array, … Read more

How to Use Elasticsearch in Laravel

Elasticsearch is one of the most popular Open-Source search engines. In addition to search, it provides a rich set of features like filtering, sorting, and aggregation. If you need to implement search using Elasticsearch in the Laravel application, you can use the official Elasticsearch client for PHP, but there is a much simpler way. Laravel … Read more

How to Fix Array to String Conversion in Laravel

This error is not directly related to Laravel, and appears whenever you try to use an array as a string without explicit conversion. However, in Laravel, you can see this error in two cases: directly when using an array in a place where your application wants string and if you haven’t configured the correct type … Read more

How to Get ENV Variable in Laravel

Laravel allows you to use .env files to define environment-specific variables. For example, a project deployed locally and a project in production will have different database connection settings, caching and queue settings, and so on. Moreover, you can also add your custom variables to the.env file and then use them in your code. However, it … Read more

How to Get Raw SQL Query in Laravel

Laravel uses the Eloquent ORM to build and execute database queries. It allows you to build complex queries with multiple conditions, grouping, and joining multiple tables. Most of the queries you may need can be built using Eloquent methods, so you almost never need to write SQL code. However, sometimes you may need to know … Read more

Laravel Development with Docker Tutorial

When I first started web development, I installed PHP, Apache, and MySQL server directly on a Windows computer, and later on Linux. At that time, builds like XAMPP were also popular, as they already contained all the necessary tools and even had a simple management interface. But I didn’t like to use such builds, because … Read more