diff --git a/.gitignore b/.gitignore index d604ecd..fe30482 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ \#* .idea .fuse* +vendor/ \ No newline at end of file diff --git a/.travis.yml b/.travis.yml index a6f38df..9fdc36e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,4 +6,7 @@ php: - 5.6 - hhvm +before_script: + - composer install --prefer-source + script: php run_tests.php diff --git a/README.md b/README.md index c8e2a58..e7c8ecf 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,31 @@ Implements IETF JSON-patch (RFC 6902) and JSON-pointer (RFC 6901): http://tools.ietf.org/html/rfc6902 http://tools.ietf.org/html/rfc6901 +Using with Composer +------------------- + +To use this library as a Composer dependency in your project, include the +following sections in your project's `composer.json` file: + +``` + "repositories": [ + { + "type": "vcs", + "url": "https://github.com/mikemccabe/json-patch-php" + } + ], + "require": { + "mikemccabe/json-patch-php": "dev-master" + } +``` + +Then, in your project's code, use the `JsonPatch` class definition from +the `mikemccabe\JsonPatch` namespace like so: + +```php +use mikemccabe\JsonPatch\JsonPatch; +``` + Entry points ------------ diff --git a/composer.json b/composer.json index 3187404..e6dfb55 100644 --- a/composer.json +++ b/composer.json @@ -2,5 +2,10 @@ "name": "mikemccabe/json-patch-php", "description": "Produce and apply json-patch objects", "type": "library", - "license": "LGPL-3.0" + "license": "LGPL-3.0", + "autoload": { + "psr-4": { + "mikemccabe\\JsonPatch\\": "src" + } + } } diff --git a/run_tests.php b/run_tests.php index e5941c9..88c73a2 100644 --- a/run_tests.php +++ b/run_tests.php @@ -3,7 +3,9 @@ // This is a simple jig for testing JsonPatch.inc against json-encoded // test files. -require_once('JsonPatch.inc'); +require 'vendor/autoload.php'; + +use mikemccabe\JsonPatch\JsonPatch; $verbose = false; diff --git a/JsonPatch.inc b/src/JsonPatch.php similarity index 99% rename from JsonPatch.inc rename to src/JsonPatch.php index fec744d..d180e5a 100644 --- a/JsonPatch.inc +++ b/src/JsonPatch.php @@ -54,8 +54,9 @@ */ +namespace mikemccabe\JsonPatch; -class JsonPatchException extends Exception { } +class JsonPatchException extends \Exception { } class JsonPatch