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.

Laravel Laravel News

Similar Articles

How to use RactJS with Laravel?

How to use RactJS with Laravel?

The standard way to start using React with your laravel application.
Read more...
Laravel overriding package translation files

Laravel overriding package translation files

How to override laravel package translation files?
Read more...
Laravel Zero: A Micro-framework for console applications

Laravel Zero: A Micro-framework for console applications

Get leverage of laravel magic to create console applications within a micro framework.
Read more...