承接 phpbook/database 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

phpbook/database

Composer 安装命令:

composer require phpbook/database

包简介

PHP Database Extension For DOCTRINE

README 文档

README

About Database

  • A lightweight DATABASE PHP extension for DOCTRINE.

Composer Install

composer require phpbook/database

Declare Configurations

/********************************************
 * 
 *  Declare Configurations
 * 
 * ******************************************/

//Connections
\PHPBook\Database\Configuration\Database::setConnection('main',
	(new \PHPBook\Database\Configuration\Connection)
		->setName('Main')
        ->setDriver([
            'driver' => 'pdo_sqlite',
            'path' => __DIR__ . '/db.sqlite'
        ])
        ->setEntitiesPathRoot('entities/root/path')
        ->setProxiesPathRoot('entities/root/path')
        ->setProxiesNamespace('App\Proxy')
        ->setMetadataCache(new \Doctrine\Common\Cache\ArrayCache)
        ->setMigratorVersion(PHPBook\Database\Configuration\MigratorVersion::$V3)
        ->setMigrationPathRoot('migration/root/path')
        ->setMigrationTable('migrations')
        ->setMigrationTableColumnVersion('version')
        ->setMigrationNamespace('\App\Migration')
        ->setEventManager($eventManager) // \Doctrine\Common\EventManager
);

\PHPBook\Database\Configuration\Database::setConnection('other',
	(new \PHPBook\Database\Configuration\Connection)
		->setName('Other')
		->setDriver([
            'driver' => 'pdo_sqlite',
            'path' => __DIR__ . '/db.sqlite'
        ])
        ->setEntitiesPathRoot('entities/root/path')
        ->setProxiesPathRoot('entities/root/path')
        ->setProxiesNamespace('App\Proxy')
        ->setMetadataCache(new \Symfony\Component\Cache\Adapter\PhpFilesAdapter('doctrine-metadata'))
        ->setQueryCache(new \Symfony\Component\Cache\Adapter\PhpFilesAdapter('doctrine-query'))
        ->setMigratorVersion(PHPBook\Database\Configuration\MigratorVersion::$V3)
        ->setMigrationPathRoot('migration/root/path')
        ->setMigrationTable('migrations')
        ->setMigrationTableColumnVersion('version')
        ->setMigrationNamespace('\App\Migration')
);

//Set default connection by connection code

\PHPBook\Database\Configuration\Database::setDefault('main');

//Getting connections

$connections = \PHPBook\Database\Configuration\Database::getConnections();

foreach($connections as $code => $connection) {

	$connection->getName(); 

	$connection->getMeta();

};

?>

Use Database

		
	//Get a Singleton Doctrine Entity Manager of a Connection or Null
    \PHPBook\Database\EntityManager::get('main');

    //Get a Singleton Default Doctrine Entity Manager or Null 
    \PHPBook\Database\EntityManager::get();

    //Execute Doctrine Migration of a Connection. Updates to the better version available.
    \PHPBook\Database\Migration::execute('main');

    //Execute Doctrine Migration in Default Connection. Updates to the better version available.
    \PHPBook\Database\Migration::execute();

    //Execute Doctrine Migration of a Connection. Updates or Downgrades to the version 201010101010.
    \PHPBook\Database\Migration::execute('main', '201010101010');

    //Execute Doctrine Migration in Default Connection. Updates or Downgrades to the version 201010101010.
    \PHPBook\Database\Migration::execute(Null, '201010101010');

    //Generate Doctrine Proxies of Entities in Default Connection. 
    //The Directory will be cleared recursively before generate, so you should have a unique folder to this proxies.
    \PHPBook\Database\Proxy::generate();

    //Generate Doctrine Proxy of Entities in a Connection.
    //The Directory will be cleared recursively before generate, so you should have a unique folder to this proxies.
    \PHPBook\Database\Proxy::generate('main');
		

Helpers

        
    //Generate an UUID version 1
    \PHPBook\Database\UUID::generate('prefix-string', 'node-alias');
    \PHPBook\Database\UUID::generate('prefix-string', '');
    \PHPBook\Database\UUID::generate('', 'node-alias');
    \PHPBook\Database\UUID::generate();

You can check the doctrine documentation to use the entity manager, migrations and other resources.

phpbook/database 适用场景与选型建议

phpbook/database 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 49 次下载、GitHub Stars 达 1, 最近一次更新时间为 2018 年 06 月 28 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「database」 「php」 「lightweight」 「fast」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 phpbook/database 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 phpbook/database 我们能提供哪些服务?
定制开发 / 二次开发

基于 phpbook/database 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 49
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 1
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-06-28