Level 58
Yes, it is possible to use Laravel Sail to work on a package. Here are the steps:
- Create a new Laravel project using Sail:
composer create-project --prefer-dist laravel/laravel my-package
cd my-package
./vendor/bin/sail up
- Create your package inside the
packagesdirectory:
mkdir packages
cd packages
mkdir my-vendor
cd my-vendor
composer create-project --prefer-dist laravel/laravel my-package
- Add your package to the main
composer.jsonfile:
"autoload": {
"psr-4": {
"App\": "app/",
"MyVendor\MyPackage\": "packages/my-vendor/my-package/src"
}
},
- Add your package to the
composer.jsonfile inside themy-packagedirectory:
"require": {
"my-vendor/my-package": "dev-master"
},
-
Run
composer updateto install your package. -
You can now use your package inside the main Laravel project.
Note: If you already have a Laravel project that uses Sail, you can follow the same steps to add a package to it. Just make sure to add the package to the main composer.json file and run composer update.