dsnetpl/doctrine-column-comment-bundle
doctrine/dbal for raw SQL operations).COMMENT ON COLUMN statements.Creating, Created) to log comments via triggers (database-dependent).| Risk Area | Severity | Mitigation Strategy |
|---|---|---|
| Doctrine Dependency | High | Abstract Doctrine via DBAL or build a proxy. |
| Migration Conflicts | Medium | Use --dry-run to preview SQL before apply. |
| Docblock Parsing | Medium | Validate syntax via PHPStan or custom linting. |
| Database Portability | High | Test on target DB (PostgreSQL/MySQL/SQLite). |
| Performance Overhead | Low | Minimal if used only in dev (comments are static). |
Why Comments?
Schema::table()->comment() suffice?Migration Strategy
Tooling Integration
make:migration)?Performance Impact
COMMENT ON COLUMN slow down queries? (Negligible in most cases, but test.)Team Adoption
doctrine/dbal to execute raw SQL comments without full Doctrine ORM.use Doctrine\DBAL\Schema\AbstractSchemaManager;
$connection = DBAL::getConnection();
$schemaManager = $connection->createSchemaManager();
$schemaManager->getDatabasePlatform()->getCommentOnColumnSQL(
'table_name',
'column_name',
'Comment from docblock'
);
Phase 1: Proof of Concept
doctrine/dbal to composer.json.--dry-run.Phase 2: Integration
// In a migration:
$this->commentOn('users', 'email', 'User\'s primary email address (from docblock)');
Schema:Updated.Phase 3: Enforcement
| Component | Compatibility | Workaround |
|---|---|---|
| Eloquent Models | Low | Requires docblock parsing logic. |
| Migrations | Medium | Custom commentOn() method needed. |
| Doctrine DBAL | High | Direct SQL execution possible. |
| PostgreSQL | High | Native COMMENT ON COLUMN support. |
| MySQL | Medium | Uses ALTER TABLE COMMENT (less precise). |
| SQLite | Low | No native support; ignore or mock. |
phpDocumentor/reflection).SHOW CREATE TABLE (MySQL) or \d table (PostgreSQL).COMMENT vs. PostgreSQL’s COMMENT ON COLUMN).$this->app['db']->select("SELECT * FROM information_schema.columns WHERE table_name = 'users'");
| Scenario | Impact | Recovery Strategy |
|---|---|---|
| Docblock syntax error | Broken migration | Fix syntax; rollback if needed. |
| Database unsupported | Silent failure | Skip comments or mock in SQLite. |
| Schema drift (comments out of sync) | Inconsistent docs | Re-generate comments via migration. |
| Performance regression | None (metadata-only) | Monitor SHOW CREATE TABLE execution time. |
string $email → COMMENT ON COLUMN users.email).How can I help you explore Laravel packages today?