Laravel integration for Neon Instagres - create instant, claimable PostgreSQL databases with zero configuration. Perfect for development, testing, CI/CD, and quick prototyping.
- π Instant databases - PostgreSQL databases in seconds, no account needed
- π¨ Laravel-native - Artisan commands, facades, and automatic .env management
- β±οΈ 72-hour lifespan - Claimable for permanent use
- π§ Zero configuration - Works immediately after installation
- π§ͺ Perfect for testing - Ideal for CI/CD pipelines and temporary environments
- π¦ Laravel 10-12 - Full support for Laravel 10.x, 11.x, and 12.x
Install the package via Composer:
composer require philip/laravel-instagresThe package will automatically register itself via Laravel's package discovery.
If you want to customize the package configuration:
php artisan vendor:publish --tag="instagres-config"This will create a config/instagres.php file where you can customize settings like the referrer name and environment variable names.
Create a new database and set it as your default connection:
php artisan instagres:create --set-defaultThis will:
- Create a new Instagres database
- Update database connection variables in your
.envfile - Display connection details and claim URL
- Save claim URL for future reference
Note: Without
--set-defaultor--save-as, the command only displays connection info in your terminal without saving to.env.
Save the database with a custom name for multiple databases:
php artisan instagres:create --save-as=stagingThis creates STAGING_CONNECTION_STRING in your .env file.
Display your stored claim URL:
php artisan instagres:claim-urlCreate a new instant PostgreSQL database.
php artisan instagres:create [options]Options:
--set-default- Set this database as the default Laravel database connection--url- UseDB_URLinstead of individualDB_*variables (only with--set-default)--save-as=NAME- Save connection with a custom prefix (e.g.,STAGINGcreatesSTAGING_CONNECTION_STRINGandSTAGING_CLAIM_URL)--force- Skip confirmation prompt when modifying .env
Note: By default,
--set-defaultuses Laravel's standardDB_CONNECTION,DB_HOST,DB_PORT, etc. variables. Add--urlto useDB_CONNECTION=pgsqlandDB_URLinstead (works with Laravel's default config).
Examples:
# Create database and display info (manual configuration)
php artisan instagres:create
# Create and set as default connection (using DB_* variables)
php artisan instagres:create --set-default
# Create and set as default using DB_URL
php artisan instagres:create --set-default --url
# Create and save as named connection
php artisan instagres:create --save-as=testing
# Create and save both ways
php artisan instagres:create --set-default --save-as=backupDisplay claim URLs for your Instagres databases.
php artisan instagres:claim-url [options]Options:
--name=NAME- Show claim URL for a specific connection (e.g.,--name=stagingshowsSTAGING_CLAIM_URL)
Default Behavior:
By default, the command displays all claim URLs found in your .env file in a table format.
Examples:
# Show all claim URLs
php artisan instagres:claim-url
# Show default claim URL
php artisan instagres:claim-url --name=default
# Show claim URL for a specific named connection
php artisan instagres:claim-url --name=staging
php artisan instagres:claim-url --name=productionExample Output:
Connection Claim URL
Default https://neon.new/database/abc-123...
Staging https://neon.new/database/def-456...
Production https://neon.new/database/ghi-789...
You can also use the Instagres facade programmatically:
use Philip\LaravelInstagres\Facades\Instagres;
// Create a database
$database = Instagres::create();
// Access database information
echo $database['connection_string'];
echo $database['claim_url'];
echo $database['expires_at'];
// Get claim URL for a database ID
$claimUrl = Instagres::claimUrl($dbId);
// Parse a connection string
$parsed = Instagres::parseConnection($database['connection_string']);
echo $parsed['host'];
echo $parsed['database'];
echo $parsed['user'];
echo $parsed['password'];
echo $parsed['dsn']; // Ready for PDO
// Generate a UUID
$uuid = Instagres::generateUuid();Once you've created a database and saved it with --set-default, you can use it like any Laravel database:
use Illuminate\Support\Facades\DB;
// Run migrations
php artisan migrate
// Query the database
$users = DB::table('users')->get();
// Use Eloquent
User::create(['name' => 'John Doe']);The config/instagres.php file contains the following options:
return [
// Referrer identifier (helps track where databases are created from)
'referrer' => env('INSTAGRES_REFERRER', 'laravel-instagres'),
// Customize the default claim URL variable name (for --set-default)
// Named connections (--save-as=staging) use {PREFIX}_CLAIM_URL
'claim_url_var' => 'INSTAGRES_CLAIM_URL',
];After creating a database with the Artisan command, these variables are automatically added to your .env:
Using --set-default (without --url):
DB_CONNECTION=pgsql
DB_HOST=ep-test-123.us-east-1.aws.neon.tech
DB_PORT=5432
DB_DATABASE=neondb
DB_USERNAME=username
DB_PASSWORD=password
# Claim URL (saved when using --set-default)
INSTAGRES_CLAIM_URL=https://neon.new/database/123e4567-e89b-12d3-a456-426614174000Using --set-default --url:
DB_CONNECTION=pgsql
DB_URL=postgresql://user:pass@host:5432/db?sslmode=require
# Claim URL (saved when using --set-default)
INSTAGRES_CLAIM_URL=https://neon.new/database/123e4567-e89b-12d3-a456-426614174000Using --save-as=staging:
# Named connection (each named connection gets its own claim URL)
STAGING_CONNECTION_STRING=postgresql://user:pass@host/db?sslmode=require
STAGING_CLAIM_URL=https://neon.new/database/123e4567-e89b-12d3-a456-426614174000Note:
- DB_ variables* (default) work great for local development and provide granular control
- DB_URL works with Laravel's default
config/database.phpfor PostgreSQL connections - Named connections automatically get their own claim URL with the same prefix (e.g.,
STAGING_CLAIM_URL) - The default claim URL variable name can be customized in
config/instagres.php
# Create a fresh database for local development
php artisan instagres:create --set-default
# Run migrations
php artisan migrate
# Seed data
php artisan db:seed# Create temporary test database
php artisan instagres:create --set-default
# Run tests
php artisan test
# Database automatically expires after 72 hours (no cleanup needed)# Create different databases for different purposes
php artisan instagres:create --save-as=development --set-default
php artisan instagres:create --save-as=staging
php artisan instagres:create --save-as=testing# Get the claim URL
php artisan instagres:claim-url
# Visit the URL in your browser
# Sign in to Neon (or create account)
# Click to claim the database
# Database becomes permanent in your Neon account- Provider: Neon Serverless PostgreSQL
- Region: AWS eu-central-1
- PostgreSQL Version: 17
- Plan: Neon Free tier
- Lifespan: 72 hours (claimable for permanent use)
- Connection: SSL required
The package throws exceptions that extend Philip\Instagres\Exception\InstagresException:
use Philip\Instagres\Exception\InstagresException;
use Philip\LaravelInstagres\Facades\Instagres;
try {
$database = Instagres::create();
} catch (InstagresException $e) {
// Handle network errors, API failures, etc.
Log::error('Failed to create database: ' . $e->getMessage());
}composer test- π§ͺ CI/CD Pipelines - Temporary databases for automated testing
- π» Local Development - Quick database setup without Docker
- π Learning & Tutorials - No-hassle database for demos
- π Prototyping - Rapid application development
- π¬ Testing - Isolated test databases
- π Data Migration Testing - Safe environment for migration testing
- Core SDK: philip/instagres
- Neon Documentation: Instagres (Launchpad)
- Neon Website: neon.com
Please see CHANGELOG for more information on what has changed recently.
Contributions are welcome! Please feel free to submit a Pull Request.
If you discover a security vulnerability, please email philip@roshambo.org.
The MIT License (MIT). Please see License File for more information.