Languages
PHP
The PHP SDK publishes to Packagist, which serves Composer.
Install
bash
composer require your-org/api-clientOptions
| Option | Values | Default |
|---|---|---|
| Client style | functions, namespaced, class, class-namespaced | functions |
| Argument style | object, positional | object |
| Namespace | tags, path | tags |
| Doc comments | full, minimal | full |
| File header | omit, include | omit |
| Usage example | full, concise | full |
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-clientThe 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;
}