How to Debug Laravel Application

If you’re developing a complex and robust application, you may encounter unexpected behavior that requires, debugging to find the root cause. While traditional debugging techniques such as Xdebug, breakpoints, and step-by-step execution are helpful, they can be time-consuming and unnecessary in many cases. One of the most popular ways to debug code is by printing … Read more

How to Change Column in Migration Laravel

Laravel allows developers to use migrations for creating database tables. However, it’s not always easy to determine in advance which columns will be needed in the future or what type of data they will store. Consequently, rarely you may want to change a column name or even its data type. You can use the renameColumn() … Read more

How to Get Route Name in Laravel

Every route in Laravel can have a name, which you can use to create URLs in your controllers with the route() helper. Sometimes you may want to find the current route name or a name of a route for a specific action. In this short article, we’ll explore how to get route name in Laravel … Read more

How to Return Exception as JSON in Laravel

Laravel has different default exceptions. For example ValidationException, AuthenticationException, NotFoundHttpException, etc. Each exception can be handled and rendered for user by its own way. For example, NotFoundHttpException usually is converted to beautiful 404 page. It is not so bad, but when AuthenticationException is thrown, Laravel just redirect user to the login page. This may work … Read more

How to Use Where Like in Laravel

Filtering using WHERE with the LIKE operator is very popular in SQL queries. You can use it to find records containing some words or symbols in the database. But Laravel does not have a dedicated method for this operator. Thus, you should use the where() method and specify the operator. In this short article, I … Read more

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 another developers team or your company wants to have documentation for your API, you can use OpenAPI Framework. Also, it is called Swagger. It is a standard system for API documentation in many companies. It is very important to have standardized up-to-date documentation because other developers will be able … 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 where you need to have some unique string, for example for HTML element identifiers, any tracking identifiers or as a primary key for Eloquent models. By default, Eloquent uses an integer as the primary key, but if this key is visible to visitors, it is better to … Read more

How to Check Laravel Version

Laravel developers are constantly adding new features to new versions of the framework. If you want to know whether your installation supports a specific feature, you should know your version of Laravel. This article will show several ways to check the Laravel version in the command line or your code. You can use the artisan … Read more