Install the Bundle
composer require ascetic-soft/rowcast-bundle:^1.1.11
Ensure RowcastBundle is registered in config/bundles.php:
AsceticSoft\RowcastBundle\RowcastBundle::class => ['all' => true],
Configure rowcast.yaml
Add a minimal config in config/packages/rowcast.yaml:
rowcast:
connection:
dsn: '%env(DATABASE_DSN)%'
username: '%env(DATABASE_USER)%'
password: '%env(DATABASE_PASSWORD)%'
First Use Case: Querying Data
Inject DataMapper into a service/repository:
use AsceticSoft\Rowcast\DataMapper;
final readonly class UserRepository {
public function __construct(private DataMapper $mapper) {}
public function findById(int $id): ?array {
return $this->mapper->findOne('users', ['id' => $id]);
}
}
Dependency Injection
DataMapper for CRUD operations (e.g., find, findOne, insert, update).$this->mapper->insert('users', ['name' => 'John', 'email' => 'john@example.com']);
Schema Management (Optional)
schema.path to a .php/.yaml file.src/Entity) with annotated classes.bin/console rowcast:migrate
Profiler Integration (Dev Only)
dev/rowcast.yaml:
rowcast:
profiler:
enabled: true
nest_transactions: true in config to auto-commit transactions per request.Connection directly for raw SQL:
$pdo = $this->connection->getPdo();
$stmt = $pdo->query("SELECT * FROM users WHERE active = 1");
public function __construct(private DataMapper $mapper) {}
Schema Parser Conflicts
schema.path points to a directory but AttributeSchemaParser is missing, fall back to file parsing. Ensure dependencies are installed:
composer require ascetic-soft/rowcast-schema
Profiler Overhead
profiler.enabled in production avoids query collection overhead.Migration Table Naming
migration_table to avoid conflicts with existing tables.rowcast.yaml:
rowcast:
connection:
options:
PDO::ATTR_ERRMODE: PDO::ERRMODE_EXCEPTION
PDO::ATTR_EMULATE_PREPARES: false
--verbose for detailed output:
bin/console rowcast:migrate --verbose
--dry-run flag to preview migrations without execution.Custom Schema Parsers
Implement AsceticSoft\RowcastSchema\Parser\SchemaParserInterface for custom schema formats.
SchemaParserRegistry for dynamic parser registration at runtime.Decorating Connection
Extend AsceticSoft\RowcastProfiler\ConnectionProfiler for query interception.
ConnectionDecorator trait for easier extension.Event Listeners
Use Symfony’s event system to hook into kernel.request/kernel.response for transaction management.
DATABASE_* env vars are set (e.g., .env):
DATABASE_DSN=mysql://localhost:3306/db_name
DATABASE_USER=user
DATABASE_PASSWORD=pass
composer.json with your own for private recipes.
--dry-run flag for previewing migrations.Connection.How can I help you explore Laravel packages today?