conserto/pomm-cli
Fork of Pomm’s CLI component for inspecting PostgreSQL databases and generating PHP classes. Configure via a simple bootstrap file returning a Pomm instance, then use commands like pomm:inspect:database/schema/relation to explore schemas, relations, and columns.
Installation
composer require conserto/pomm-cli:^4.0
Ensure pomm-project/pomm is also installed (core dependency). This version now includes Symfony 8 compatibility.
First Command Run the basic Pomm CLI to verify installation:
php artisan pomm:cli
This initializes an interactive Pomm shell with updated Symfony 8 integration.
Quick Use Case Connect to a PostgreSQL server via CLI:
php artisan pomm:cli --server=postgresql://user:pass@localhost:5432/dbname
Then use Pomm’s shell commands (e.g., describe, execute) to interact with the database.
php artisan to list available pomm:cli options.php artisan pomm:cli --help for CLI-specific flags.composer.json.Database Migration Scripts Use the CLI to automate schema checks or data validation before migrations:
php artisan pomm:cli --server=postgresql://... --execute="SELECT * FROM migrations WHERE applied = false;"
Testing Environments Spin up disposable Pomm connections for tests (ensure Symfony 8 components are compatible):
// In a test case
$this->artisan('pomm:cli', [
'--server' => 'postgresql://test:test@localhost:5432/test_db',
'--execute' => 'SELECT 1;'
]);
Debugging Queries Pipe query results to a file for analysis:
php artisan pomm:cli --server=... --execute="SELECT * FROM large_table;" --output=query_results.json
.env and reference them via --server=$DB_CONNECTION.php artisan pomm:cli --server=... --execute="SELECT id FROM users;" | xargs -I{} php artisan pomm:cli --execute="DELETE FROM users WHERE id={};"
PommCliServiceProvider (ensure compatibility with Symfony 8 components).Connection Timeouts
--timeout=300 to increase the timeout (default: 30s).Output Formatting
--format=json for machine-readable output or --limit=100 to cap results.Shell Escaping
' or ;) may break the CLI.--file=query.sql to load from a file.Symfony 8 Dependency Conflicts
composer why-not symfony/... to check for conflicts and update composer.json constraints accordingly.--verbose to see raw Pomm logs.--dry-run to simulate queries without execution.try {
$this->artisan('pomm:cli', ['--execute' => 'INVALID_QUERY;']);
} catch (\Exception $e) {
// Handle error (e.g., log or notify)
}
Custom Commands
Register new CLI commands by extending PommCliServiceProvider:
// app/Providers/PommCliServiceProvider.php
public function register()
{
$this->commands([
\App\Console\Commands\CustomPommCommand::class,
]);
}
Ensure custom commands are compatible with Symfony 8 components.
Query Templates
Store reusable queries in resources/pomm/ and reference them via --file=path/to/query.sql.
Environment Variables
Dynamically load server configs from .env:
php artisan pomm:cli --server=${DB_DSN} --execute="${QUERY}"
config/pomm.php:
'default' => [
'server' => env('DB_DSN', 'postgresql://default:user@localhost'),
],
--interactive or configure ~/.pommrc for credentials.config/pomm.php aligns with Symfony 8’s dependency injection and configuration standards.How can I help you explore Laravel packages today?