Octri

Languages

PHP

The PHP SDK publishes to Packagist, which serves Composer.

Install

bash
composer require your-org/api-client

Options

OptionValuesDefault
Client stylefunctions, namespaced, class, class-namespacedfunctions
Argument styleobject, positionalobject
Namespacetags, pathtags
Doc commentsfull, minimalfull
File headeromit, includeomit
Usage examplefull, concisefull
class fits PHP's conventions

PHP consumers expect new Acme\Client(...). Set Client style to class or class-namespaced for PHP.

Package name

Packagist names are always vendor/package:

text
acme/api-client

The vendor segment is claimed by whoever registers first, so register yours before you need it.

Packagist reads from your repository

This is the part that surprises people coming from npm.

Packagist doesn't host your code, it points at your repo

Composer resolves packages from Packagist, but Packagist stores only metadata and fetches the code from the git repository and its tags. A release is a tag in your repo, and Packagist picks it up via a webhook.

That means the PHP Repository isn't optional decoration: without it there's nothing for Packagist to read. Set it per language. See Publishing.

What callers write

php
<?php

use Acme\Client;

$client = new Client(getenv('ACME_TOKEN'));

foreach ($client->users->list(['limit' => 100]) as $user) {
    echo $user->id . PHP_EOL;
}