Creating Laravel Package from Scratch

Cerwyn Cahyono
7 min readJan 10, 2021
Photo by Giftpundits.com from Pexels

Are you a developer? If yes, I’m sure that you must always add some packages/libraries to your project. I’m a Laravel developer, maybe you too. And inside Laravel, we have so many useful packages that ready to use, make life easier for us. What do you need? Do you want an API Authentication? You have Laravel Passport/Sanctum. Need a monitoring queue job? You have Horizon. Or maybe other packages from other developers/companies like Spatie Laravel Permission for managing roles and permissions. And trust me, there are so many more packages that useful for our projects. Just a little tip from me, if you want to build something for your client/company’s need, maybe it’s best for you to find first the package that fulfills your needs. If there is, then you save your time and enjoy.

But, what if there are no packages out there that fulfill your needs? Or maybe you’re already built something right now and think that maybe your works are worth it to be available publicly as a package. So that, people, or even yourselves, can reuse your package. I’ve built a lot of websites using Laravel, and sometimes I always create the same functions/classes same and same again in different projects. Maybe you feel that way too, the same way I feel. It’s better if we convert our functions/classes to a package then we can install it wherever we want.

--

--

Cerwyn Cahyono

PHP/Backend Engineer at Undercurrent Capital Pte Ltd — Data Science Enthusiast