Dipendra Gurung
Dipendra Gurung

Reputation: 5900

How to create your own package for composer create-project

Laravel uses:

composer create-project laravel/laravel your-project-name --prefer-dist

How can I make my own package so that I can use

composer create-project mycompany/projectx your-project-name --prefer-dist

Can I use bitbucket a private repository for this ?

Upvotes: 9

Views: 11453

Answers (2)

Wouter J
Wouter J

Reputation: 41954

As long as the package is available on packagist.org, you can use the composer create-project command.

If you don't want to put your package on packagist, please refer to composer create-project from private repo:

Like so...

composer create-project vendor/name path --repository-url=http://repo.yourcomposerrepo.com

Since you won't submit a private package to packagist. That url just needs a packages.json file at minimum, you could use satis or your own packagist if you want a more dynamic solution to the packages.json.

You can also just use git clone and then execute composer install yourself.

Upvotes: 8

edi9999
edi9999

Reputation: 20574

They is nothing special to do for you package to be installable with composer create-project.

Just declare you dependencies in the composer.json of your package if you have any. The command will just copy the package into the current directory, than run composer install

You can use a private repository if you use authentification over ssh, for example:

{
    "require": {
        "vendor/my-private-repo": "dev-master"
    },
    "repositories": [
        {
            "type": "vcs",
            "url":  "[email protected]:vendor/my-private-repo.git"
        }
    ]
}

See https://getcomposer.org/doc/05-repositories.md

Upvotes: 1

Related Questions