PHP develop your own package with local composer environment

PHP develop your own package with local composer environment

Apr 17, 2019 / Ramesh Mhetre

Developing your own PHP composer package locally & integrating local file symlink within your application can speeds up development immensely. It also gives you a platform to test out your package in real application on real time.

I've learned this workflow by reading out multiple articles online recently. So I thought I'll create my own version of it.

Basic PHP package setup

There are different ways to create your own package with all necessary setup included. There are different boilerplate/skeleton projects for creating packages like Spatie's PHP Skeleton or The PHP League Skeleton. Even you can create your own package setup as per your requirements.

Package development local directory structure

In my case the package I work on multiple applications on the same time & I use my packages in the multiple applications. On my development environment I always use development copy of my package also so I can modify easily when working on any project. Here is how my structure looks like:

PHP Package Development Environment

PHP Package Development Environment

Composer file setup for local package development

Your project/application composer file should look something like this:

 {
    .
    .
    "require": {
         .
         .
         "xyz/your-awesome-package": "*",
    }
    "repositories": {
         "whatever": {
             "type": "path",
             "url": "../packages/your-awesome-package"
         }
    }
}

This setup helps me really speed up my package development & usage on the application.


Similar Articles

What is new to Laravel 6?

What is new to Laravel 6?

Today Laravel 6 has finally officially released. Let's have a detailed look at what is changing in Laravel 6.
Read more...
Connect your laravel application to Sqlite DB

Connect your laravel application to Sqlite DB

Quickly connecting with sqlite database within laravel application
Read more...
Laravel v6 & Laravel Vapor is going to release soon 🚀

Laravel v6 & Laravel Vapor is going to release soon 🚀

Laravel v6 is is releasing soon. Serverless laravel is next big thing in laravel community!
Read more...