What are Laravel packages and how to install them

- Andrés Cruz

En español
What are Laravel packages and how to install them

The packages in Laravel are a piece of software or if you want to see it a little more generally, they are a set of software or plugins that are created with the purpose of solving some deficiency or adding extra functionality to a system as in this case it would be Laravel.

What are the packages?

We are going to introduce what a package is in PHP to understand its importance more easily; a package is nothing more than a set of related classes and functions that are grouped together in a reusable library; this package commonly seeks to solve a problem, such as exporting an excel file, generating a PDF, sending an email, etc.

 PHP packages can be distributed through GitHub or in general any repository with which we can install them through Composer or manually

The packages are generally developed by third parties and in the case of Laravel they can be written specifically for this framework or simply for php; if we review, for example, Laravel's dependencies, we will see that there are many packages apart from Laravel's; these packages are framework dependencies and of course, we can install more

Some of these packages may be paid for but they also have multiple packages that we can use for free in our projects; free of cost and of excellent quality.

And a package for Laravel is nothing more than a PHP package developed exclusively for Laravel.

What types of packages exist

As I told you at the beginning, a package is simply a piece of software that comes to solve some lack: therefore you can find all kinds of packages for all kinds of developments; process images, graphics, social login, roles, qr and a long etc.

Get the idea by visiting the following page

Their importance lies in the fact that they are pieces of software developed by other programmers who are largely dedicated to the theme of the package they are developing, be it image processing, integration with social networks through login, skeletons that already provide us with a completely functional and customizable like JetStream with Livewire etc; therefore, in many cases, they are pieces of software created by experts in the area that allow us to take advantage of their development for free or not.

Packages in Laravel

Laravel packages are developed exclusively for Laravel, therefore they cannot be used directly in native PHP or other frameworks; with these packages, we can add additional functionality to an existing Laravel application without having to develop the functionality from scratch. Laravel packages follow a specific structure and typically include a composer.json file that specifies the package's dependencies and requirements, as well as a README.md file that provides detailed documentation on how to use the package. Laravel also has its own ecosystem of online packages, available through Composer, which allows developers to discover and use additional packages in their applications.

How are packages made?

Packages for Laravel can have multiple web technologies; therefore its scope is infinite; They have PHP code as you might expect, but they can also have client-side technologies, for example CSS, JS and HTML in any of their variants, client-side library frameworks, etc. PHP packages can actually be made up of a large number of technologies and components, depending on their specific purpose and function. However, some of the common components that can be found in PHP packages include class and function libraries, controllers.

Install a package in Laravel

To install a package in Laravel, you simply have to select the one you want, and add the dependency or run composer require and composer adds the package for you in the composer.json, downloads and installs it in the project and we are ready to use the package; For example, if we wanted to install the following intervention/image package:

composer require intervention/image

Composer to install packages

As you can see, most of the packages require composer to be able to be used in the framework, since manual package installations are long gone; It is important to note that some packages require additional configuration in the project; the best reference is the one provided by the developer himself.

Andrés Cruz

Desarrollo con Laravel, Django, Flask, CodeIgniter, HTML5, CSS3, MySQL, JavaScript, Vue, Android, iOS, Flutter

Andrés Cruz en Udemy

Acepto recibir anuncios de interes sobre este Blog.