1. Go to this page and download the library: Download holokron/json-patch library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
holokron / json-patch example snippets
namespace Example\Handler;
use Example\Entity\Account;
class UserHandler
{
public function add($value)
{
$value = json_encode($value);
echo "UserHandler::add($value)\n";
}
public function remove(int $id)
{
echo "UserHandler::remove($id)\n";
}
public function replace(string $id, array $value)
{
$value = json_encode($value);
echo "UserHandler::replace($id)($value)\n";
}
}
use Example\Handler\UserHandler;
use Holokron\JsonPatch as JsonPatch;
$accountHandler = new UserHandler();
$builder = new JsonPatch\Definition\Builder();
$definitions = $builder
->op('add')
->path('/users')
->callback([$handler, 'add'])
->add()
->op('remove')
->path('/users/:userId')
->callback([$handler, 'remove'])
->
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.