Use your own PHP library via composer

1. Create your library, with a composer.json as below, and commit it to github (for example, https://github.com/umbalaconmeogia/yii2-batsg)

composer.json

{
    "name": "umbalaconmeogia/yii2-batsg"
}

2. To use yii2-batst in a project (installing via composer), create composer.json as below in the project and run composer install.

composer install

composer.json

{
    "repositories": [
        {
            "type": "vcs",
            "url": "https://github.com/umbalaconmeogia/yii2-batsg"
        }
    ],
    "require": {
	    "umbalaconmeogia/yii2-batsg": "dev-master"
	}
}

Now, your library (yii2-batsg) is used in another project.

3. In the step 2 above, you should add the repository url of yii2-batsg into composer.json. To eliminate this work, publish yii2-batsg to Packagist
Go to https://packagist.org/packages/submit . Follow its very simple steps to register your github repository.

4. To update only your library (yii2-batsg) in your project, run composer in your project

composer update umbalaconmeogia/yii2-batsg
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: