Create your own Laravel package

Starting from now, you can develop or create your own The Laravel package for supporting your work as Laravel Developer.

There are 2 two the Laravel boilerplate generator for Laravel and PHP Package which are beyondcode and spatie

For beyondcode as an example, because it is easier to download and can fill in some information about the package such as vendor name, package name, author name, and email. Next, you need to a few steps to start developing your package.

Create a folder inside your Laravel app

After you downloaded the files. you can copy it into your Laravel project with the packages folder.

|-app
|-packages
|---your-vendor-name
|-----your-package-name

After that, you need to inside the package folder and then run the composer install command.

cd packages/your-vendor-name/your-package-name
composer install

Install your package

To install your package, you need to register your package into the main composer.json file

{
  "repositories": [
    {
      "type": "path",
      "url": "./packages/your-vendor-name/your-package-name"
    }
  ]
}

and then run composer require your-vendor-name/your-package-name && composer dump-autoload on the root of the Laravel app.

Start Developing

Basically, you start developing and implementing your logic of the package. In case you have added a PHP Class inside your package, you need to run composer dump-autoload on the root Laravel app.

Enjoy Your Laravel Developer Life!!!