Skip to content

Commit a793943

Browse files
authored
Merge pull request #12 from cyon/composer-and-namespaces
Using composer and PSR-4 namespaces
2 parents c7ebf36 + 25099be commit a793943

106 files changed

Lines changed: 1423 additions & 592 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
11
.idea
2+
3+
/vendor/
4+
composer.lock

.travis.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,6 @@ notifications:
77
email:
88
- kill-bill-commits@googlegroups.com
99

10-
script: phpunit --coverage-text test
10+
install: composer install
11+
12+
script: composer test

README.md

Lines changed: 55 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,70 @@
11
killbill-client-php
22
===================
33

4-
PHP client library for killbill
4+
PHP client library for [Killbill](http://killbill.io)
55

66
Configuration
77
-------------
88

9-
In order to user the library, you need to:
9+
In order to use the library, you need to:
1010

11-
1. Download the library and unzip it in your application
12-
2. Require the `lib/killbill.php` script
13-
3. Point the library to your Killbill instance via the `Killbill_Client::$serverUrl` variable (http://127.0.0.1:8080 by default)
11+
1. Require the library via [composer](https://getcomposer.org): `composer require killbill\killbill-client`
12+
2. Point the library to your Killbill instance via the `Client::$serverUrl` variable (http://127.0.0.1:8080 by default)
1413

1514
Example
1615
-------
1716

18-
We have a Killbill instance running at http://cloudkilling.org:8080 you can play with. The following snippet will create an account:
19-
20-
// Path to the library
21-
require_once(dirname(__FILE__) . '/lib/killbill.php');
22-
23-
// Killbill server
24-
Killbill_Client::$serverUrl = "http://cloudkilling.org:8080";
25-
26-
// Set these values for your particular tenant
27-
$tenant = new Killbill_Tenant();
28-
$tenant->apiKey = 'bob';
29-
$tenant->apiSecret = 'lazar';
30-
31-
// Unique id for this account
32-
$externalAccountId = uniqid();
33-
34-
// Prepare the account data
35-
$accountData = new Killbill_Account();
36-
$accountData->name = "Killbill php test";
37-
$accountData->externalKey = $externalAccountId;
38-
$accountData->email = "test-" . $externalAccountId . "@kill-bill.org";
39-
$accountData->currency = "USD";
40-
$accountData->paymentMethodId = null;
41-
$accountData->address1 = "12 rue des ecoles";
42-
$accountData->address2 = "Poitier";
43-
$accountData->company = "Renault";
44-
$accountData->state = "Poitou";
45-
$accountData->country = "France";
46-
$accountData->phone = "81 53 26 56";
47-
$accountData->length = 4;
48-
$accountData->billCycleDay = 12;
49-
$accountData->timeZone = "UTC";
50-
51-
// Create it
52-
$createdAccount = $accountData->create("pierre", "PHP_TEST", "Test for " . $externalAccountId, $tenant->getTenantHeaders());
17+
The following snippet will create an account:
5318

19+
```php
20+
<?php
21+
22+
use \Killbill\Client\Client;
23+
use \Killbill\Client\Tenant;
24+
use \Killbill\Client\Account;
25+
26+
// Killbill server
27+
Client::$serverUrl = "http://localhost:8080";
28+
29+
// Set these values for your particular tenant
30+
$tenant = new Tenant();
31+
$tenant->apiKey = 'bob';
32+
$tenant->apiSecret = 'lazar';
33+
34+
// Unique id for this account
35+
$externalAccountId = uniqid();
36+
37+
// Prepare the account data
38+
$accountData = new Account();
39+
$accountData->name = "Killbill php test";
40+
$accountData->externalKey = $externalAccountId;
41+
$accountData->email = "test-" . $externalAccountId . "@kill-bill.org";
42+
$accountData->currency = "USD";
43+
$accountData->paymentMethodId = null;
44+
$accountData->address1 = "12 rue des ecoles";
45+
$accountData->address2 = "Poitier";
46+
$accountData->company = "Renault";
47+
$accountData->state = "Poitou";
48+
$accountData->country = "France";
49+
$accountData->phone = "81 53 26 56";
50+
$accountData->length = 4;
51+
$accountData->billCycleDay = 12;
52+
$accountData->timeZone = "UTC";
53+
54+
// Create it
55+
$createdAccount = $accountData->create("pierre", "PHP_TEST", "Test for " . $externalAccountId, $tenant->getTenantHeaders());
56+
```
57+
58+
Using the client in a non-composer environment
59+
----------------------------------------------
60+
61+
If you want to use the client but are not using [Composer](https://getcomposer.org) (yet), follow these steps:
62+
63+
- Install composer locally: [Instruction](https://getcomposer.org/doc/00-intro.md#installation-linux-unix-osx)
64+
- Run `composer require killbill/killbill-client`. This will download the library into the `vendor/` folder and create a `composer.json` and a `composer.lock` file that define this dependency.
65+
- Include the auto-generated `autoload.php` file from the `vendor/` folder.
66+
- You can now use the client like above described.
67+
- If you don't want to have an additional build step, just check the `vendor/` folder into your repository.
5468

5569
Requirements
5670
------------
@@ -61,4 +75,4 @@ The PHP library requires PHP 5.3.0 or greater with _libcurl_ compiled (e.g. you
6175
Support
6276
-------
6377

64-
Feel free to ask questions on the [killbilling-users](https://groups.google.com/forum/?fromgroups#!forum/killbilling-users) Google Group.
78+
Feel free to ask questions on the [killbilling-users](https://groups.google.com/forum/?fromgroups#!forum/killbilling-users) Google Group.

composer.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"name": "killbill/killbill-client",
3+
"description": "Official PHP client to the Killbill HTTP API",
4+
"type": "library",
5+
"autoload": {
6+
"psr-4": {
7+
"Killbill\\Client\\": "src/"
8+
}
9+
},
10+
"autoload-dev": {
11+
"psr-4": {
12+
"Killbill\\Client\\": "test/"
13+
}
14+
},
15+
"scripts": {
16+
"test": "phpunit"
17+
},
18+
"license": "Apache",
19+
"require": {},
20+
"require-dev": {
21+
"phpunit/phpunit": "^4.8"
22+
}
23+
}

lib/killbill.php

Lines changed: 0 additions & 34 deletions
This file was deleted.

lib/killbill/account.php

Lines changed: 0 additions & 102 deletions
This file was deleted.

lib/killbill/gen/killbill_bundle_timeline_attributes.php

Lines changed: 0 additions & 35 deletions
This file was deleted.

lib/killbill/tenant.php

Lines changed: 0 additions & 47 deletions
This file was deleted.

phpunit.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="utf-8" ?>
2-
<phpunit>
2+
<phpunit bootstrap="vendor/autoload.php">
33
<testsuite name='Kill Bill PHP client test suite'>
4-
<directory suffix='_test.php'>./test</directory>
4+
<directory suffix='Test.php'>./test</directory>
55
</testsuite>
66
</phpunit>

0 commit comments

Comments
 (0)