Laravel package development¶
Notes¶
If any point, something doesn't make sense, or you made some changes in composer.json of your package: do these (in your test laravel project, not the package project) to ensure the slate is clean:
- Clear bootstrap/cache folder content, don't delete the folder
- Delete vendor folder
- Delete composer.lock
- composer install
- composer dump-autoload
- Re-require your package
- If none of these work: call an exorcist. Trust me, it worked.
Resc¶
- https://laravelpackage.com/02-development-environment/
- [!] https://github.com/spatie/package-skeleton-laravel
Steps¶
-
git init
(duh) -
composer init
-
add
.gitignore
/vendor/ /.idea/ composer.lock **/coverage/ .phpunit.result.cache /.phpunit.cache/ /clover.xml
-
Create basic folder structure
- /src
-
/tests
-
Add orchestra. Enables laravel mocking environment. For type-hint and stuff.
-
Integrate into an actual laravel project for local development and testing purposes
composer create-project laravel/laravel example-app
cd example-app
composer install
- Add repository target for your package, do this in the laravel project's
composer.json
:"repositories": [ { "type": "path", "url": "../path-to-your-package", "options": { "symlink": true } } ],
composer install
composer require username/package-name:dev-master
(username/package-name should be identical withname
key in your package'scomposer.json
.composer install
composer require --dev "orchestra/testbench"