Laravel Package Boilerplate
Starting point for Laravel package development. This is developed for Laravel 5.6 and up., (*1)
What this package comes with:, (*2)
Migrations
Model/Controllers
Routes/Views
Webpack / Laravel Mix / VueJS
PHPUnit
, (*3)
Getting Started
In your laravel installation root directory, create folder packages/se468
, and run composer install
, (*4)
In your laravel installation root directory, in composer.json
, add the package namespace:, (*5)
"psr-4": {
"App\\": "app/",
"se468\\PackageBoilerplate\\" : "packages/se468/laravel-package-boilerplate/src"
}
In config/app.php
, in the providers array, add, (*6)
se468\PackageBoilerplate\PackageServiceProvider::class,
Run these commands to set up the dependencies:, (*7)
composer install
Go to route /package-boilerplate
and see if you see Hello world. If you did, congratulations!, (*8)
Setting up webpack and laravel-mix
In your package directory, run the following commands., (*9)
npm install
npm install webpack -D
Now try running:, (*10)
npm run dev
and check if it creates compiled js/css in public directory., (*11)
Then, run php artisan vendor:publish --tag=public --force
to publish your assets., (*12)
Rename
Rename everything to match your own:
* Your Github ID - example: se468
* PackageNamespace - example: LaravelPackageBoilerplate
* Your Package Folder - example: laravel-package-boilerplate, (*13)
Checklist
Inside Laravel:, (*14)
1. composer.json
2. config/app.php
For your package:, (*15)
1. Rename packages/se468 to your own github id
2. PackageServiceProvider
3. composer.json
4. anywhere else you need to change
Remove any features you don't need from the boilerplate., (*16)