2 Phorge API
muke edited this page 2026-03-02 11:14:28 +01:00
This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

Phorge API — Beispiele (Maniphest)

Diese Seite dokumentiert einfache Beispiele für APIAufrufe gegen Phorge (Conduit), speziell maniphest.search.

Voraussetzungen

  • APIURL und API_TOKEN in der lokalen .env (oder als EnvironmentVariablen im Container) setzen.

Beispiel: Einzelnes Ticket per ID (curl)

curl -sS https://staging-phorge.wikonia.net/api/maniphest.search \
  -d api.token=${API_TOKEN} \
  -d "constraints[ids][0]=1024"

Beispiel: 5 Tickets (mit Cursor/Limit)

curl -sS https://staging-phorge.wikonia.net/api/maniphest.search \
  -d api.token=${API_TOKEN} \
  -d limit=5

PHP (cURL) Beispiel

$ch = curl_init('https://staging-phorge.wikonia.net/api/maniphest.search');
$params = [
  'api.token' => getenv('API_TOKEN'),
  'constraints[ids][0]' => 1024,
];
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($params));
$response = curl_exec($ch);
if ($response === false) {
    throw new Exception('Curl-Error: ' . curl_error($ch));
}
$data = json_decode($response, true);
print_r($data);

Hinweise

  • Achte auf sichere Handhabung des API_TOKEN. Die .env ist in diesem Repo in .gitignore; commit den Token nicht.
  • Für Schreiboperationen (z. B. maniphest.edit) teste zuerst im DryRun / Staging.

Beispiel: maniphest.edit mit TransactionsBuilder (PHP)

use App\Tasks\TransactionsBuilder;

$builder = (new TransactionsBuilder())
  ->addTitle('Ticket via Builder')
  ->addDescription('Erstellt via TransactionsBuilder')
  ->addProjects(['PHID-PROJ-abc']);

$params = ['transactions' => $builder->build(), 'api.token' => getenv('API_TOKEN')];

$ch = curl_init(rtrim(getenv('API_URL'), '/') . '/maniphest.edit');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($params));
$resp = curl_exec($ch);
curl_close($ch);

echo $resp;

Wichtig: Wenn du parent/Subtask setzen willst, nutze ['type'=>'parent','value'=>'PHID-TASK-...'] bzw. TransactionsBuilder::addParent().