In my experience, learning to develop a package for Laravel can be quite challenging which is why I previously wrote a blog series about that .

Over time, I began thinking this topic deserves its own manual, rather than a couple of posts which only cover my insights. That's where I think this e-book type of guide will come in. I've bundled up my blog posts and expanded on a couple of more topics in separate chapters. These chapters are available on GitHub and contributions (in the form of pull requests) are highly welcomed. I hope that this website can become a place to share knowledge on Laravel package development to help developers get a head start.

You are highly encouraged to participate and contribute to this project . Please feel free to submit a PR, even only for a typo.

First of all, I want to thank Marcel Pociot. His very clear, structured and detailed PHP Package Development video course helped me quickly getting started on developing my own packages. I can highly recommend his video course if you want to learn how to create (framework agnostic) PHP packages.

# Reasons to develop a package

You might encounter a scenario where you want to reuse some feature(s) of your application in other applications, open source a certain functionality or just keep related code together but separate it from your main application. In those cases, it makes sense to extract parts to a package. Packages or “libraries” provide an easy way to add additional functionality to existing applications, and are mostly focused on a single feature.

# Composer & Packagist

At the time of writing, there are nearly 240,000 packages available on Packagist , the main repository for PHP packages.

Packages are downloaded and installed using Composer - PHP’s package management system - which manages dependencies within a project.

To install a package in your existing Laravel project, the composer require <vendor>/<package> command will download all necessary files into a /vendor directory of your project where all your third party packages live, separated by vendor name. As a consequence, the content from these packages is separated from your application code which means this piece of code is maintained by someone else, most often by creator of that package. Whenever the package needs an update, run composer update to get the latest (compatible) version of your packages.

In the first chapter, the basic structure of a package will be addressed. Now, it can be cumbersome to set-up the basic skeleton everytime from scratch. That's why others created some helpful tools.