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

Top 8 Useful Symfony Packages

Symfony is a popular framework for the PHP language that has its own dedicated composer plugins and bundles designed for use within the Symfony ecosystem. However, It can be challenging to integrate them into other projects. Fortunately, Symfony also has many simple independent packages that can be installed using composer in any project, making your … 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 Read XLSX File Into Array

Sometimes you may need to import some data from an XLSX file into your application. The first step is to load data from the file into an array. There are a few libraries that can help with this. Each library has its advantages and disadvantages and may be the best solution in a specific case. … 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 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 Fix your App Key is Missing in Laravel

Laravel can encrypt data in database fields such as passwords. However, you must have configured the encryption key in the APP_KEY environment variable. If the variable is empty or the key has an invalid format, you will get an error. In this short article, I will explain how to fix the “your app key is … 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 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