Package development Laravel

Package development in Laravel is kinda complicated - well to begin with. Once you've figured it out, as with all things, it is pretty easy.


The first thing you'll want to do is go to this site to begin


https://www.laravelpackage.com/


I'm using the Laravel package boiler plate generator to get started. This allows you to download a zipped boiler plate template with all the class and namespaces to get you started.


There are some things to bear in mind. For testing your package, you'll need to install a special package named 'Orchestra' and that has to use PHP Unit, instead of Pest. There most probably may be a way to use Pest, but most of the documentation is for PHP Unit.


The second thing to think about, after you have a proof of concept working, is how to go about testing your package locally.


For this, you'll need to create a special composer.json file, where your package is symlinked. Once this is done, you need to do a 'composer update' for everything to work. We'll assume you have git cloned your package, into a base Laravel app.


In order to run your tests you need to cd into your git cloned directory and run a 'composer install.' If you're using the refresh database trait, you will also need to set this up correctly. Finally, to test you run the command './vendor/bin/phpunit.'


The third thing you will need to do, in order for your package to be available for all, is to register it on packagist, which is the global repository for composer.


Finally, with that being done you will need to go into github, and create a v1 tag and release. This will update the connection with packagist and thereby composer.


Now your package is available to all.