net_bazzline/php_propel_behavior_entity_instantiator 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

net_bazzline/php_propel_behavior_entity_instantiator

最新稳定版本:3.0.0

Composer 安装命令:

composer require net_bazzline/php_propel_behavior_entity_instantiator

包简介

This free as in freedom behavior that easy up entity instantiation for propel

README 文档

README

I still like the idea but there is currently no use case to develop it anymore.

Entity Instantiator Generator Behavior for Propel

This free as in freedom behavior that easy up entity instantiation for your propel query and object classes.

Thanks to the ExtraPropertiesBehavior to act as such a great template.

The build status of the current master branch is tracked by Travis CI: Build Status Latest stable

The scrutinizer status are: code quality | build status

The versioneye status is: dependencies

Downloads: Downloads this Month

It is available at openhub.net.

If you want to control things in more detail, you should have a look to the locator generator component for php and its propel examples

The current change log can be found here.

Why

  • no new in your code anymore
  • no static Query::create call in your code anymore
  • eases up writing test code (createMyEntity and createMyEntityQuery can be mocked)

Usage

  • make sure you have extension=pdo_sqlite.so enabled if you want to run phpunit
  • the behavior creates a instantiator class and file
  • the behavior has following parameters
    • entity_instantiator_add_to_entity_instantiator - ("true"|"false") allowed to add or not add this table to the instantiator, default is true
    • entity_instantiator_class_name - (string) that represents the class name, default is DatabaseEntityInstantiator
    • entity_instantiator_extends - (string) that represents the full qualified class name, default is ``
    • entity_instantiator_indention- (string) that represents the indention in the instantiator, default is
    • entity_instantiator_namespace- (string) that represents the namespace in the instantiator, default is `` (no namespace)
    • entity_instantiator_path_to_output- (string) that represents the path (relative to vendor/../) where the instantiator file will be written, default is data
    • entity_instantiator_method_name_prefix- (string) that represents the prefix for each instantiation method in the instantiator, default is create<DatabaseName>
    • entity_instantiator_default_connection_mode - (string) that represents the content of the second optional argument in Propel::getConnection($name, $mode)
    • entity_instantiator_default_connection_name - (string) that represents the content of the first optional argument in Propel::getConnection($name, $mode)
    • entity_instantiator_use_fully_qualified_name - ("true"|"false") allows to switch usage between fully qualified name or class name, default is false

Example

Given a database with following settings

<database name="exampleDatabase">
    <behavior name="add_to_entity_instantiator">
        <parameter name="entity_instantiator_class_name" value="MyEntityInstantiator" />
        <parameter name="entity_instantiator_extends" value="MyAbstractEntityInstantiator" />
        <parameter name="entity_instantiator_indention" value="  " />
        <parameter name="entity_instantiator_namespace" value="Database\Service" />
        <parameter name="entity_instantiator_path_to_output" value="module/Database/src/Database/Service" />
        <parameter name="entity_instantiator_method_name_prefix" value="create" />
        <paramater name="entity_instantiator_default_connection_name" value="exampleDatabase" />
        <paramater name="entity_instantiator_default_connection_mode" value="Propel::CONNECTION_READ" />
        <paramater name="entity_instantiator_use_fully_qualified_name" value="true" />
    </behavior>
    
    <table name="user">
        <column name="id" type="INTEGER" primaryKey="true" autoincrement="true" />
        <column name="name" type="VARCHAR" size="255" />
        
        <!-- turn it on - default -->
        <behavior name="add_to_entity_instantiator">
            <parameter name="entity_instantiator_add_to_entity_instantiator" value="true" />
        </behavior>
    </table>
    
    <table name="product">
        <column name="id" type="INTEGER" primaryKey="true" autoincrement="true" />
        <column name="name" type="VARCHAR" size="255" />
        
        <!-- turn it on -->
        <behavior name="add_to_entity_instantiator">
            <parameter name="entity_instantiator_add_to_entity_instantiator" value="false" />
        </behavior>
    </table>
</database>

will create a file called MyEntityInstantiator.php in the path module/Database/src/Database/Service with following content.

<?php

namespace Database\Service;

use PDO;
use Propel;

/**
 * Class MyEntityInstantiator
 *
 * @author Net\Bazzline\Propel\Behavior\EntityInstantiatorNet\Bazzline\Propel\Behavior\EntityInstantiator\EntityInstantiatorGenerator
 * @since 2015-08-29
 * @see http://www.bazzline.net
 */
class MyEntityInstantiator extends MyAbstractEntityInstantiator
{
    /** 
     * @return PDO
     */
    public function getConnection($name = 'exampleDatabase', $mode = \Propel::CONNECTION_WRITE)
    {   
        return Propel::getConnection($name, $mode);
    }   

    /** 
     * @return \Database\User
     */
    public function createUser()
    {   
        return new \Database\User();
    }   

    /** 
     * @return \Database\UserQuery
     */
    public function createUserQuery()
    {   
        return new \Database\UserQuery::create();
    }   
}   

Installation

By Hand

mkdir -p vendor/net_bazzline/php_propel_behavior_entity_instantiator
cd vendor/net_bazzline/php_propel_behavior_entity_instantiator
git clone https://github.com/bazzline/php_propel_behavior_entity_instantiator

With Packagist

"net_bazzline/php_propel_behavior_entity_instantiator": "dev-master"

Enable Behavior in Propel

  • add the following to your propel.ini
propel.behavior.create_entity_instantiator.class = lib.vendor.net_bazzline.php_propel_behavior_create_entity.source.AddToEntityInstantiatorBehavior

API

API available at bazzline.net

Final Words

Star it if you like it :-). Add issues if you need it. Pull patches if you enjoy it. Write a blog entry if you use it. Donate something if you love it :-].

net_bazzline/php_propel_behavior_entity_instantiator 适用场景与选型建议

net_bazzline/php_propel_behavior_entity_instantiator 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.4k 次下载、GitHub Stars 达 2, 最近一次更新时间为 2015 年 08 月 30 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

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

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

  • Stars: 2
  • Watchers: 6
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: LGPL-3.0
  • 更新时间: 2015-08-30