How to Run a Specific Test in Laravel

Laravel framework allows you to run tests using the artisan command since the 7.1.1 version. But it runs all available tests. If you want to run a specific test file or a specific test case, you should use additional options. In this short article, I will explain how to run a specific test in Laravel … Read more

How to Use Swagger in Laravel

If you need to interact with a third-party development team or your company wants documentation for an REST APIs you’re developing, you can use the OpenAPI Framework, also called Swagger. It is a standard API documentation system used in many companies. It’s crucial to have standardized, up-to-date documentation so that other developers can easily learn … Read more

How to Upload File in Laravel API Using Postman

In many cases, you may need the ability to upload one or multiple files to a Laravel application. If you use API, you can do it in various ways. Many APIs require files to be encoded as base64 string and sent as POST field. But it is not very convenient for testing and validation. You … Read more

How to Generate UUID in Laravel

UUID, or universally unique identifier, can be used when you need to have some unique string, for example, for HTML element identifiers, any tracking identifiers, or as a primary key for Eloquent models. It is better to use UUID as an identifier publicly because it is more secure than incrementing identifiers. In this short article, … 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 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