Skip to content

Commit b3af30a

Browse files
committed
Merge pull request #9 from ycombinator/master
Make this project usable via Composer
2 parents 0e342fd + 877aa64 commit b3af30a

File tree

6 files changed

+40
-3
lines changed

6 files changed

+40
-3
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
\#*
33
.idea
44
.fuse*
5+
vendor/

.travis.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,7 @@ php:
66
- 5.6
77
- hhvm
88

9+
before_script:
10+
- composer install --prefer-source
11+
912
script: php run_tests.php

README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,31 @@ Implements IETF JSON-patch (RFC 6902) and JSON-pointer (RFC 6901):
88
http://tools.ietf.org/html/rfc6902
99
http://tools.ietf.org/html/rfc6901
1010

11+
Using with Composer
12+
-------------------
13+
14+
To use this library as a Composer dependency in your project, include the
15+
following sections in your project's `composer.json` file:
16+
17+
```
18+
"repositories": [
19+
{
20+
"type": "vcs",
21+
"url": "https://github.com/mikemccabe/json-patch-php"
22+
}
23+
],
24+
"require": {
25+
"mikemccabe/json-patch-php": "dev-master"
26+
}
27+
```
28+
29+
Then, in your project's code, use the `JsonPatch` class definition from
30+
the `mikemccabe\JsonPatch` namespace like so:
31+
32+
```php
33+
use mikemccabe\JsonPatch\JsonPatch;
34+
```
35+
1136
Entry points
1237
------------
1338

composer.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,10 @@
22
"name": "mikemccabe/json-patch-php",
33
"description": "Produce and apply json-patch objects",
44
"type": "library",
5-
"license": "LGPL-3.0"
5+
"license": "LGPL-3.0",
6+
"autoload": {
7+
"psr-4": {
8+
"mikemccabe\\JsonPatch\\": "src"
9+
}
10+
}
611
}

run_tests.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
// This is a simple jig for testing JsonPatch.inc against json-encoded
44
// test files.
55

6-
require_once('JsonPatch.inc');
6+
require 'vendor/autoload.php';
7+
8+
use mikemccabe\JsonPatch\JsonPatch;
79

810
$verbose = false;
911

JsonPatch.inc renamed to src/JsonPatch.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,9 @@
5454
5555
*/
5656

57+
namespace mikemccabe\JsonPatch;
5758

58-
class JsonPatchException extends Exception { }
59+
class JsonPatchException extends \Exception { }
5960

6061

6162
class JsonPatch

0 commit comments

Comments
 (0)