|
| 1 | +# Balanced |
| 2 | + |
| 3 | +Online Marketplace Payments |
| 4 | + |
| 5 | +[](http://travis-ci.org/balanced/balanced-php) |
| 6 | + |
| 7 | +The design of this library was heavily influenced by [Httpful](https://github.com/nategood/httpful). |
| 8 | + |
| 9 | +## Requirements |
| 10 | + |
| 11 | +- [PHP](http://www.php.net) >= 5.3 **with** [cURL](http://www.php.net/manual/en/curl.installation.php) |
| 12 | +- [RESTful](https://github.com/bninja/restful) >= 0.1 |
| 13 | +- [Httpful](https://github.com/nategood/httpful) >= 0.1 |
| 14 | + |
| 15 | +## Issues |
| 16 | + |
| 17 | +Please use appropriately tagged github [issues](https://github.com/balanced/balanced-php/issues) to request features or report bugs. |
| 18 | + |
| 19 | +## Installation |
| 20 | + |
| 21 | +You can install using [composer](#composer), a [phar](#phar) package or from [source](#source). Note that Balanced is [PSR-0](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-0.md) compliant: |
| 22 | + |
| 23 | +### Composer |
| 24 | + |
| 25 | +If you don't have Composer [install](http://getcomposer.org/doc/00-intro.md#installation) it: |
| 26 | + |
| 27 | + $ curl -s https://getcomposer.org/installer | php |
| 28 | + |
| 29 | +Add this to your `composer.json`: |
| 30 | + |
| 31 | + { |
| 32 | + "require": { |
| 33 | + "balanced/balanced": "*" |
| 34 | + } |
| 35 | + } |
| 36 | + |
| 37 | +Refresh your dependencies: |
| 38 | + |
| 39 | + $ php composer.phar update |
| 40 | + |
| 41 | + |
| 42 | +Then make sure to `require` the autoloader and initialize all: |
| 43 | + |
| 44 | + <?php |
| 45 | + require(__DIR__ . '/vendor/autoload.php'); |
| 46 | + |
| 47 | + \Httpful\Bootstrap::init(); |
| 48 | + \RESTful\Bootstrap::init(); |
| 49 | + \Balanced\Bootstrap::init(); |
| 50 | + ... |
| 51 | + |
| 52 | +### Phar |
| 53 | + |
| 54 | +Download an Httpful [phar](http://php.net/manual/en/book.phar.php) file, which are all [here](https://github.com/nategood/httpful/downloads): |
| 55 | + |
| 56 | + $ curl -s -L -o httpful.phar https://github.com/downloads/nategood/httpful/httpful.phar |
| 57 | + |
| 58 | +Download a RESTful [phar](http://php.net/manual/en/book.phar.php) file, which are all [here](https://github.com/bninja/restful/downloads): |
| 59 | + |
| 60 | + $ curl -s -L -o restful.phar https://github.com/bninja/restful/downloads/restful.phar |
| 61 | + |
| 62 | +Download a Balanced [phar](http://php.net/manual/en/book.phar.php) file, which are all [here](https://github.com/balanced/balanced-php/downloads): |
| 63 | + |
| 64 | + $ curl -s -L -o balanced.phar https://github.com/balanced/balanced-php/downloads/balanced-{VERSION}.phar |
| 65 | + |
| 66 | +And then `include` all: |
| 67 | + |
| 68 | + <?php |
| 69 | + include(__DIR__ . '/httpful.phar'); |
| 70 | + include(__DIR__ . '/restful.phar'); |
| 71 | + include(__DIR__ . '/balanced.phar'); |
| 72 | + ... |
| 73 | + |
| 74 | +### Source |
| 75 | + |
| 76 | +Download [Httpful](https://github.com/nategood/httpful) source: |
| 77 | + |
| 78 | + $ curl -s -L -o httpful.zip https://github.com/nategood/httpful/zipball/master; |
| 79 | + $ unzip httpful.zip; mv nategood-httpful* httpful; rm httpful.zip |
| 80 | + |
| 81 | +Download [RESTful](https://github.com/bninja/restful) source: |
| 82 | + |
| 83 | + $ curl -s -L -o restful.zip https://github.com/bninja/restful/zipball/master; |
| 84 | + $ unzip restful.zip; mv bninja-restful* restful; rm restful.zips |
| 85 | + |
| 86 | +Download the Balanced source: |
| 87 | + |
| 88 | + $ curl -s -L -o balanced.zip https://github.com/balanced/balanced-php/zipball/master |
| 89 | + $ unzip balanced.zip; mv balanced-balanced-php-* balanced; rm balanced.zip |
| 90 | + |
| 91 | +And then `require` all bootstrap files: |
| 92 | + |
| 93 | + <?php |
| 94 | + require(__DIR__ . "/httpful/bootstrap.php") |
| 95 | + require(__DIR__ . "/restful/bootstrap.php") |
| 96 | + require(__DIR__ . "/balanced/bootstrap.php") |
| 97 | + ... |
| 98 | + |
| 99 | +## Quickstart |
| 100 | + |
| 101 | + curl -s http://getcomposer.org/installer | php |
| 102 | + |
| 103 | + echo '{ |
| 104 | + "require": { |
| 105 | + "balanced/balanced": "*" |
| 106 | + } |
| 107 | + }' > composer.json |
| 108 | + |
| 109 | + php composer.phar install |
| 110 | + |
| 111 | + curl https://raw.github.com/balanced/balanced-php/master/example/example.php > example.php |
| 112 | + |
| 113 | + php example.php |
| 114 | + |
| 115 | + curl https://raw.github.com/balanced/balanced-php/master/example/buyer-example.php > buyer-example.php |
| 116 | + |
| 117 | + php -S 127.0.0.1:9321 buyer-example.php |
| 118 | + # now open a browser and go to http://127.0.0.1:9321/ to view how to tokenize cards and add to a buyer |
| 119 | + |
| 120 | +## Usage |
| 121 | + |
| 122 | +See https://www.balancedpayments.com/docs/overview?language=php for tutorials and documentation. |
| 123 | + |
| 124 | +## Testing |
| 125 | + |
| 126 | + $ phpunit --bootstrap vendor/autoload.php tests/ |
| 127 | + |
| 128 | +Or if you'd like to skip network calls: |
| 129 | + |
| 130 | + $ phpunit --exclude-group suite --bootstrap vendor/autoload.php tests/ |
| 131 | + |
| 132 | +## Publishing |
| 133 | + |
| 134 | +1. Ensure that **all** [tests](#testing) pass |
| 135 | +2. Increment minor `VERSION` in `src/Balanced/Settings` and `composer.json` (`git commit -am 'v{VERSION} release'`) |
| 136 | +3. Tag it (`git tag -a v{VERSION} -m 'v{VERSION} release'`) |
| 137 | +4. Push the tag (`git push --tag`) |
| 138 | +5. [Packagist](http://packagist.org/packages/balanced/balanced) will see the new tag and take it from there |
| 139 | +6. Build (`build-phar`) and upload a [phar](http://php.net/manual/en/book.phar.php) file |
| 140 | + |
| 141 | +## Contributing |
| 142 | + |
| 143 | +1. Fork it |
| 144 | +2. Create your feature branch (`git checkout -b my-new-feature`) |
| 145 | +3. Write your code **and [tests](#testing)** |
| 146 | +4. Ensure all tests still pass (`phpunit --bootstrap vendor/autoload.php tests/`) |
| 147 | +5. Commit your changes (`git commit -am 'Add some feature'`) |
| 148 | +6. Push to the branch (`git push origin my-new-feature`) |
| 149 | +7. Create new pull request |
| 150 | + |
| 151 | +## Contributors |
| 152 | + |
| 153 | +* [Jacob Rus](https://github.com/jrus) |
| 154 | +* [Leon Smith](https://github.com/leonsmith) |
| 155 | +* [Matt Drollette](https://github.com/MDrollette) |
| 156 | +* [You](https://github.com/balanced/balanced-php/issues)! |
0 commit comments