This package is meant to provide a reference when you're following along with the documentation on LaravelPackage.com. Along the way, we'll build a demo package (called "BlogPackage") by introducing the functionalities (as listed below) one-by-one. When something doesn't work as expected in your own package, you might use this repository to quickly find out if the bug is in your package or in the documentation (by running this package's test suite).
The demo package features the following components:
- Package Service Provider
- Database migrations
- Commands
- Configuration (config file)
- Models
- Routes
- Views
- Assets
- Controllers
- Events & Listeners
- Facades
- Middleware
- Mailables
- Traits
- Database Factories (for testing purposes)
- Clone this repository:
git clone [email protected]:Jhnbrn90/BlogPackage.git
- Install the dependencies:
composer install
- Confirm by running all tests:
composer test
Now you're free to use this demo package to your advantage. You can also include the demo package in a Laravel project if you wish, check the section below.
You can easily use this packge in a local Laravel project, after cloning:
- Specify a new repository in your composer.json file of the Laravel project (not this package!):
// composer.json
{
"repositories": [
{
"type": "path",
"url": "../../blogpackage" // the relative path to your package
}
]
}
- Require the package in the local Laravel project:
composer require johndoe/blogpackage
- Optionally publish the package assets:
php artisan vendor:publish --provider="JohnDoe\BlogPackage\BlogPackageServiceProvider" --tag="config"
php artisan vendor:publish --provider="JohnDoe\BlogPackage\BlogPackageServiceProvider" --tag="migrations"
php artisan vendor:publish --provider="JohnDoe\BlogPackage\BlogPackageServiceProvider" --tag="views"
php artisan vendor:publish --provider="JohnDoe\BlogPackage\BlogPackageServiceProvider" --tag="assets"
This package includes a Unit and Feature test suite covering all mentioned components. You can easily run all tests for this package using composer test
, or a specific test using composer test-f test-name-here
.