alhames/db-bundle

Symfony AlhamesDbBundle

安装: 690

依赖者: 0

建议者: 0

安全: 0

星标: 0

关注者: 1

分支: 0

公开问题: 2

类型:symfony-bundle

v2.0.4 2024-04-20 17:59 UTC

This package is auto-updated.

Last update: 2024-09-20 18:59:22 UTC


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: ~