alhames / db-bundle
Symfony AlhamesDbBundle
v2.0.4
2024-04-20 17:59 UTC
Requires
- php: ^7.4 || ^8.0
- ext-mysqli: *
- psr/log: ^1.1|^2|^3
- symfony/cache-contracts: ^2.0|^3.0
- symfony/framework-bundle: ^5.4|^6.0|^7.0
Requires (Dev)
- phpunit/phpunit: ^9.0
- symfony/yaml: ^5.4|^6.0|^7.0
Suggests
- symfony/web-profiler-bundle: To use the data collector.
README
Symfony 为 MySQL/MariaDB 数据库的 Bundle
安装
使用 Symfony Flex 的应用程序
打开命令控制台,进入您的项目目录并执行
$ composer require alhames/db-bundle
不使用 Symfony Flex 的应用程序
步骤 1: 下载 Bundle
打开命令控制台,进入您的项目目录并执行以下命令以下载此 Bundle 的最新稳定版本
$ composer require alhames/db-bundle
此命令需要您全局安装了 Composer,详情请参阅 Composer 文档中的安装章节。
步骤 2: 启用 Bundle
然后,通过将其添加到项目 app/AppKernel.php
文件中注册的 Bundle 列表中来启用该 Bundle
<?php // app/AppKernel.php // ... class AppKernel extends Kernel { public function registerBundles() { $bundles = array( // ... new \Alhames\DbBundle\AlhamesDbBundle(), ); // ... } // ... }
配置
完整的默认配置
alhames_db: default_connection: 'default' default_database: ~ cache: ~ # null or service name logger: ~ # null, false or service name query_formatter: ~ # null or service name connections: # Prototype name: host: '127.0.0.1' username: 'root' password: '' database: ~ port: 3306 charset: 'utf8mb4' tables: # Prototype name: table: ~ database: ~ connection: ~