How to Get Domain From URL in PHP

Sometimes, you may need to extract the domain or some other parts from an URL. It is a very straightforward task that can be done using the built-in parse_url() function without any external libraries. However, third-party libraries can provide more convenience and power to handle URLs In this short article, I will show how to … 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

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

By default, when something throws an exception when accessing an API in Laravel, it is not always returned in a JSON response. A JSON response is returned only when the client explicitly indicates that they want to receive JSON in the response. In all other cases, plain HTML code will be returned, or even a … Read more

How to Read XLSX File Into Array in PHP

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