Read the root README first. This page covers common options and behavior.
Pass your app name as ref. Turn on logical replication when you need it.
$database = Client::createClaimableDatabase(
ref: 'my-php-app',
enableLogicalReplication: true
);$database = Client::getDatabase($databaseId);After someone claims the database, connection_string may be null. Open the Neon console to get connection details.
$connections = Client::getConnectionStrings($somePooledOrDirectUrl);
echo "Pooled: {$connections['pooled']}\n";
echo "Direct: {$connections['direct']}\n";Use pooled URLs for typical app traffic. Use direct URLs for migrations and admin tools. See reference for throws and edge cases.
Claimable Postgres provisions databases on AWS us-east-2 with PostgreSQL 17. Unclaimed databases expire after 72 hours unless you claim them into a Neon account.
- Open
claim_urlfrom the API response. You can also opengetClaimUrl($id)if you only store the id. - Sign in to Neon and finish the claim flow.
- Local development and tests
- Quick prototypes and demos
- CI jobs that need a temporary Postgres URL
Catch InstagresException to handle all SDK errors in one place.
use Philip\Instagres\Client;
use Philip\Instagres\Exception\InstagresException;
try {
$database = Client::createClaimableDatabase();
} catch (InstagresException $e) {
echo "Error: {$e->getMessage()}\n";
}Exception types (all extend InstagresException):
InvalidArgumentException. Emptyref, empty database id, bad input togetConnectionStrings(), or JSON encode failure on the create payload.NetworkException. Transport or non-success HTTP with a message from the API when present.InvalidResponseException. Response JSON is missing fields or invalid for the expected shape.
composer install
php examples/create-database.php
php examples/comprehensive.phpSet INSTAGRES_LIVE=1 before comprehensive.php if you want live API calls.
Seed a sample schema:
php examples/seed-database.phpSee examples/seed-database.php and examples/sample-schema.sql.
composer test