A simple PHP SDK for creating instant claimable Neon PostgreSQL databases with zero configuration.
This SDK provides a PHP implementation of Neon's Instagres (formerly Launchpad) feature, allowing you to provision PostgreSQL databases instantly without account creation.
- 🚀 Instant database provisioning (no account/auth needed)
- 🔗 Immediate connection string availability
- ⏱️ 72-hour database lifespan (claimable for permanent use)
- 🎯 Simple, clean implementation using industry-standard libraries
- 🐘 Requires PHP 8.1+
composer require philip/instagres<?php
require_once 'vendor/autoload.php';
use Philip\Instagres\Client;
// Create a claimable database (uses default referrer: 'instagres-php')
$database = Client::createClaimableDatabase();
echo "Connection String: {$database['connection_string']}\n";
echo "Claim URL: {$database['claim_url']}\n";
echo "Expires At: {$database['expires_at']}\n";If you've cloned the repository, you can run the included examples:
composer install
php examples/create-database.phpWant to create a database with initial data? Seed with the included sample schema:
php examples/seed-database.phpThis example demonstrates:
- Creating a database with Instagres
- Connecting using PDO
- Executing SQL from a file
- Verifying the seeded data
- Real-world database setup patterns
See examples/seed-database.php and examples/sample-schema.sql for the complete implementation.
# Run all tests
composer test
# Run tests with coverage report (generates HTML in coverage/ directory)
composer test:coveragecreateClaimableDatabase(
string $referrer = 'instagres-php',
?string $dbId = null
): arrayCreates a claimable Neon database and returns connection information.
Parameters:
$referrer(string, optional): An identifier for your application (default:'instagres-php')$dbId(string|null, optional): Custom UUID for the database (auto-generated if not provided)
Returns: Array with keys:
connection_string(string): PostgreSQL connection stringclaim_url(string): URL to claim the database to your Neon accountexpires_at(string): Expiration timestamp in ISO 8601 format (e.g., "2025-11-15T15:22:03Z")
Throws:
NetworkException- If HTTP request fails or returns non-success statusInvalidResponseException- If API response is invalid or missing required fields
getClaimUrl(string $dbId): stringGets the claim URL for a database. This URL is used to claim the temporary database into a Neon account, otherwise it expires (is deleted) after 72 hours.
Parameters:
$dbId(string, required): The database UUID
Returns: The claim URL
parseConnectionString(string $connectionString): arrayParses a PostgreSQL connection string into individual components and PDO-ready format.
Parameters:
$connectionString(string, required): PostgreSQL connection string (e.g.,postgresql://user:pass@host/db)
Returns: Array with keys:
host(string): Database hostport(string): Port number (defaults to 5432 if not specified)database(string): Database nameuser(string): Usernamepassword(string): Password (URL-decoded)dsn(string): PDO DSN string ready for use withnew PDO()options(array): Query string options (e.g.,['sslmode' => 'require'])
Throws:
InvalidResponseException- If connection string format is invalid
Example:
$database = Client::createClaimableDatabase();
// The returned connection string URI looks similar to:
// postgresql://user:pass@ep-jolly-fog.eu-central-1.aws.neon.tech/neondb?channel_binding=require&sslmode=require
$parsed = Client::parseConnectionString($database['connection_string']);
// Use with PDO
$pdo = new PDO($parsed['dsn'], $parsed['user'], $parsed['password']);
// Or access individual components
echo "Host: {$parsed['host']}\n";
echo "Port: {$parsed['port']}\n";
echo "Database: {$parsed['database']}\n";Databases are provisioned on AWS (eu-central-1) running PostgreSQL 17 with Neon Free plan limits. They expire after 72 hours unless claimed.
To persist your database beyond 72 hours:
- Visit the claim URL
- Sign in to your Neon account (or create one)
- Follow the instructions to claim the database (click a button)
- Development and testing environments
- Quick prototyping
- Evaluating Neon before committing to an account
- CI/CD pipelines requiring temporary databases
- Demo applications
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:
NetworkException- HTTP/network failuresInvalidResponseException- Invalid API responses
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.
Contributions are welcome! Please feel free to submit a Pull Request.