Create a private composer package repo

Php

Source code

touch “src/HelloWorld.php”

1
2
3
4
5
6
7
<?php
namespace CalvinLam;
class HelloWorld{
public function say(){
echo "Hello world!";
}
}

touch “composer.json”

1
2
3
4
5
6
7
8
9
10
11
12
13
14
{
"license": "proprietary",
"name": "calvinlam/hello-world",
"description": "calvinlam's test composer package",
"minimum-stability": "dev",
"require": {
},
"autoload": {
"psr-4": {
"CalvinLam\\": "src/"
}

}
}

Develop your package locally

1
composer dump-autoload # or composer install
1
2
3
4
<?php
require("vendor/autoload.php");
\CalvinLam\HelloWorld::say();
echo "done";

Download your private package

  • config your private repo OAuth access
  • touch composer.json
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    {
    "repositories": [
    {
    "url": "https://bitbucket.org/calvin-lam/php-composer-module-hello-world.git",
    "type": "git"
    }
    ],
    "require": {
    "calvinlam/hello-world": "dev-master"
    },
    "config": {
    "bitbucket-oauth": {
    "consumer-key": "xxxxx",
    "consumer-secret": "yyyyyy"
    }
    }
    }