Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 ?

like image 421
Dipendra Gurung Avatar asked May 27 '14 07:05

Dipendra Gurung


People also ask

How do I create a new composer project?

Project template for creating and initializing a new PHP project from with a composer project or a composer package is named PHP Project from Composer . Open the New Project window in File / New / Project menu, choose PHP Project from Composer , and specify the new project location.

What is composer package?

Package# Composer is a dependency manager. It installs packages locally. A package is essentially a directory containing something. In this case it is PHP code, but in theory it could be anything.


2 Answers

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.

like image 179
Wouter J Avatar answered Nov 07 '22 04:11

Wouter J


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

like image 27
edi9999 Avatar answered Nov 07 '22 03:11

edi9999