PHP code example of hop-top / cite
1. Go to this page and download the library: Download hop-top/cite 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/ */
hop-top / cite example snippets
use HopTop\Cite\Scheme;
$parsed = Scheme::parse("task://hop-top/cite/T-0001");
echo $parsed->namespace; // hop-top/cite
echo $parsed->id; // T-0001
use HopTop\Cite\ActionRoute;
use HopTop\Cite\Policy;
use HopTop\Cite\Scheme;
$policy = new Policy(
defaultNamespaceSegments: 1,
schemeNamespaceSegments: ["tlc" => 2],
actionRoutes: [
"task.claim" => new ActionRoute(
command: "tlc",
args: ["-C", "{namespace}", "task", "claim", "{id}"],
),
],
);
$parsed = Scheme::parse("tlc://org/repo/T-0001?name=task&action=claim", $policy);
$plan = $policy->resolveAction($parsed);
print_r($plan->args); // ["-C", "org/repo", "task", "claim", "T-0001"]
use HopTop\Cite\Policy;
use HopTop\Cite\Scheme;
use HopTop\Cite\VanityAlias;
$policy = new Policy(
defaultNamespaceSegments: 1,
schemeNamespaceSegments: ["task" => 2],
vanityAliases: [
new VanityAlias(
from: "task://shortcut",
to: "task://hop-top/cite/T-0001",
prefix: true,
preserveSuffix: true,
),
],
);
$parsed = Scheme::parse("task://shortcut/child", $policy);
echo $parsed->canonical(); // task://hop-top/cite/T-0001/child