{"id":37006478,"url":"https://github.com/lindelius/php-json-patch","last_synced_at":"2026-01-14T00:45:28.653Z","repository":{"id":45350245,"uuid":"370151518","full_name":"lindelius/php-json-patch","owner":"lindelius","description":"A zero-dependency PHP implementation of JSON Patch","archived":false,"fork":false,"pushed_at":"2021-12-18T23:45:20.000Z","size":77,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-11-22T01:19:54.961Z","etag":null,"topics":["json","json-patch"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lindelius.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-05-23T20:30:54.000Z","updated_at":"2023-05-26T21:35:52.000Z","dependencies_parsed_at":"2022-08-29T22:10:27.585Z","dependency_job_id":null,"html_url":"https://github.com/lindelius/php-json-patch","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/lindelius/php-json-patch","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lindelius%2Fphp-json-patch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lindelius%2Fphp-json-patch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lindelius%2Fphp-json-patch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lindelius%2Fphp-json-patch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lindelius","download_url":"https://codeload.github.com/lindelius/php-json-patch/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lindelius%2Fphp-json-patch/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28406526,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-13T21:51:37.118Z","status":"ssl_error","status_checked_at":"2026-01-13T21:45:14.585Z","response_time":56,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["json","json-patch"],"created_at":"2026-01-14T00:45:27.899Z","updated_at":"2026-01-14T00:45:28.637Z","avatar_url":"https://github.com/lindelius.png","language":"PHP","readme":"# php-json-patch\n\n[![CircleCI](https://circleci.com/gh/lindelius/php-json-patch.svg?style=shield)](https://circleci.com/gh/lindelius/php-json-patch)\n[![Coverage Status](https://coveralls.io/repos/github/lindelius/php-json-patch/badge.svg?branch=master)](https://coveralls.io/github/lindelius/php-json-patch?branch=master)\n\nA zero-dependency PHP implementation of JSON Patch ([RFC 6902](https://tools.ietf.org/html/rfc6902)).\n\n## Table of Contents\n\n- [Requirements](#requirements)\n- [Installation](#installation)\n- [Usage](#usage)\n    - [Protected Paths](#protected-paths)\n\n## Requirements\n\n- PHP 7.4, or higher\n\n## Installation\n\nIf you are using Composer, you may install the latest version of this library by running the following command from your project's root folder:\n\n```\ncomposer require lindelius/php-json-patch\n```\n\nYou may also manually download the library by navigating to the \"Releases\" page and then expanding the \"Assets\" section\nof the latest release.\n\n## Usage\n\nGiven a set of JSON Patch operations...\n\n```json\n[\n    { \"op\": \"test\", \"path\": \"/name\", \"value\": \"Anakin Skywalker\" },\n    { \"op\": \"replace\", \"path\": \"/name\", \"value\": \"Darth Vader\" },\n    { \"op\": \"add\", \"path\": \"/order\", \"value\": \"Sith\" },\n    { \"op\": \"move\", \"from\": \"/friends\", \"path\": \"/foes\" }\n]\n```\n\nAnd a document...\n\n```json\n{\n    \"name\": \"Anakin Skywalker\",\n    \"friends\": [\"Obi-Wan Kenobi\", \"Ahsoka Tano\"],\n    \"order\": \"Jedi\"\n}\n```\n\nYou can (atomically) apply the patches through one of the [`PatcherInterface`](src/PatcherInterface.php) methods...\n\n```php\n// Option 1: Provide the raw JSON string\n$newDocument = $patcher-\u003epatchFromJson($documentAsArray, $operationsAsJson);\n\n// Option 2: Provide the JSON Patch operations in array format\n$newDocument = $patcher-\u003epatch($documentAsArray, $operationsAsArray);\n```\n\nAnd get a new document back :)\n\n```json\n{\n    \"name\": \"Darth Vader\",\n    \"foes\": [\"Obi-Wan Kenobi\", \"Ahsoka Tano\"],\n    \"order\": \"Sith\"\n}\n```\n\n### Protected Paths\n\nThis library has built-in support for registering \"protected paths\", which are paths that may not be modified by any patch operation. Protected paths will indirectly also block modifications to their parent path(s) and any child paths.\n\n```php\n$patcher-\u003eaddProtectedPath(\"/id\");\n$patcher-\u003eaddProtectedPath(\"/created_at\");\n$patcher-\u003eaddProtectedPath(\"/some/nested/path\");\n```\n\nPlease note that \"test\" operations can still operate on a protected path since they are not actually modifying the document.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flindelius%2Fphp-json-patch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flindelius%2Fphp-json-patch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flindelius%2Fphp-json-patch/lists"}