Skip to content

Commit

Permalink
add build script to create phar archive (closes #18)
Browse files Browse the repository at this point in the history
  • Loading branch information
darthmaim committed Jul 11, 2015
1 parent eeb4477 commit 74a4b58
Show file tree
Hide file tree
Showing 5 changed files with 96 additions and 3 deletions.
21 changes: 20 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,31 @@

## Setup

### Using [composer](https://getcomposer.org):
### Using [composer](https://getcomposer.org) (recommended)

```sh
composer require gw2treasures/gw2api
```

If you haven't included composers autoloader yet,
you will have to add this before being able to use the GW2 API Wrapper.

```php
include 'vendor/autoload.php';
```

### Using the gw2api.phar archive

You need to download the [latest gw2api.phar](https://github.com/GW2Treasures/gw2api/releases/tag/latest)
and the [guzzle.phar of the latest 5.x version](https://github.com/guzzle/guzzle/releases/tag/5.3.0) of the
[guzzle](https://github.com/guzzle/guzzle) library and place both files in your project directory.
Now you can include both files to start using the GW2 API wrapper.

```php
include __DIR__ . '/gw2api.phar';
include __DIR__ . '/guzzle.phar';
```

## Examples

```php
Expand Down
1 change: 1 addition & 0 deletions build/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
artifacts/
31 changes: 31 additions & 0 deletions build/build.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

// directory paths
$baseDirectory = realpath(__DIR__.'/..');
$buildDirectory = $baseDirectory . '/build';
$artifactsDirectory = $buildDirectory . '/artifacts';
$stagingDirectory = $artifactsDirectory . '/staging';

// create all needed directories.
if( !file_exists( $artifactsDirectory )) {
mkdir($artifactsDirectory);
}

// setup packager
require $baseDirectory . '/vendor/mtdowling/burgomaster/src/Burgomaster.php';
$packager = new \Burgomaster( $stagingDirectory, $baseDirectory );

// include readme and license files
foreach(['README.md', 'LICENSE'] as $file) {
$packager->deepCopy( $file, $file );
}

// include source
$packager->recursiveCopy( 'src', 'GW2Treasures/GW2Api', ['php'] );

// create the autoloader
$packager->createAutoloader();

// build phar and zip archives
$packager->createPhar( $buildDirectory . '/artifacts/gw2api.phar');
$packager->createZip( $buildDirectory . '/artifacts/gw2api.zip');
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
},
"require-dev": {
"phpunit/phpunit": "~4.6",
"satooshi/php-coveralls": "dev-master"
"satooshi/php-coveralls": "dev-master",
"mtdowling/burgomaster": "^0.0.2"
},
"autoload": {
"psr-4": {
Expand Down
43 changes: 42 additions & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 74a4b58

Please sign in to comment.