Developing Laravel Packages
@flyingluscas
Lucas Pires
@flyingluscas

Developer for almost 4 years now,
but only 2 with Laravel :)
Currently working as a developer at Pagar.me, best job ever!
Why develop packages?
Reuse of code, versioning, and community.
Structure
The structure of a Laravel Package.

Service Providers
The bridge between Laravel and your package.
Basically, register and boot stuff!
The Register Method
Bind things into the service container.
Don't register any event listeners, routes, or any
other piece of functionality!
The Boot Method
Bootstrap any application services.
You have access to all other services
that have been registered.
Deferred Providers
When your provider is only registering
bindings in the service container.
Deferring the loading of such a provider will improve the performance of your application.
Package Discovery
Laravel will automatically register its service providers and facades when it is installed, creating a convenient installation experience for your package's users.
Configuration
Allow users of your package to easily override
your default configuration options.
Routes
Load your routes using the
loadRoutesFrom method.
Automatically check for cached routes.
Migrations
Load your migrations using
the loadMigrationsFrom method.
Automatically run migrations when the migrate command is executed.
Views
Load your views using
the loadViewsFrom method.
Package views are referenced using the package::view syntax convention.
Testing
How to write tests for a Laravel package?
Testing Frameworks
- PHPUnit
- Orchestral Testbench
- Laravel Dusk
Final Tips
- Follow PSR-2 & PSR-4
- Keep a Changelog
- StyleCI, CodeClimate
- Write tests!
- TDD
- Follow Semantic Versioning
- Use Packagist
Many Thanks!
Congrats, you've reached the end of the universe, now go back!
Developing Laravel Packages @flyingluscas
Developing Laravel Packages
By Lucas Pires
Developing Laravel Packages
Tips & tricks about the development of packages for Laravel.
- 797