Phase 2 sub-commit 1: Doctrine ORM 3 + Migrations + SQLite
Some checks failed
CI / Quality (push) Has been cancelled
Some checks failed
CI / Quality (push) Has been cancelled
Skeleton gains Doctrine ORM 3.6 (with DoctrineBundle 3.x and Migrations 4.x), pointed at a SQLite file under var/data.sqlite. Apps move to Postgres/MySQL by overriding DATABASE_URL in .env.local. config/packages/doctrine.yaml registers the symfony/uid UuidType so Phase 2 sub-commit 4's UUIDv7 default works without per-app config, and pre-wires the App\Entity attribute mapping under src/Entity/ for the maker to drop entities into. Bundle gains an optional doctrine/dbal Connection via Autowire; when present, bridge:doctor adds a "Database reachable" SELECT-1 probe. The bundle still installs cleanly without doctrine/dbal — apps that opt out get a doctor table without the database row. Verified: `bin/console bridge:doctor` is all green against a fresh SQLite. composer quality (PHPStan + cs-fixer + PHPUnit) stays green. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -4,6 +4,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace PhpQml\Bridge\Command;
|
||||
|
||||
use Doctrine\DBAL\Connection;
|
||||
use Symfony\Component\Console\Attribute\AsCommand;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
@@ -30,6 +31,9 @@ final class BridgeDoctorCommand extends Command
|
||||
private readonly string $mercurePublisherKey,
|
||||
#[Autowire('%env(default::MERCURE_SUBSCRIBER_JWT_KEY)%')]
|
||||
private readonly string $mercureSubscriberKey,
|
||||
// Optional: present only if the application installs doctrine/dbal.
|
||||
#[Autowire(service: 'doctrine.dbal.default_connection')]
|
||||
private readonly ?Connection $dbConnection = null,
|
||||
) {
|
||||
parent::__construct();
|
||||
}
|
||||
@@ -68,6 +72,15 @@ final class BridgeDoctorCommand extends Command
|
||||
'Set MERCURE_SUBSCRIBER_JWT_KEY in .env.local; or rely on the Caddy `anonymous` directive in dev mode.'],
|
||||
];
|
||||
|
||||
if (null !== $this->dbConnection) {
|
||||
try {
|
||||
$this->dbConnection->fetchOne('SELECT 1');
|
||||
$checks[] = ['Database reachable', true, ''];
|
||||
} catch (\Throwable $e) {
|
||||
$checks[] = ['Database reachable', false, 'Connection failed: '.$e->getMessage()];
|
||||
}
|
||||
}
|
||||
|
||||
$rows = [];
|
||||
$allPass = true;
|
||||
foreach ($checks as [$label, $ok, $hint]) {
|
||||
|
||||
Reference in New Issue
Block a user