vladmeh / zftool
Zend Framework 1 Mapper Models Generator 的 Zend Tool CLI 提供商
Requires
- php: >=5.2.11
Requires (Dev)
- phpunit/dbunit: 1.3.*
- phpunit/phpunit: 3.7.*
- zendframework/zendframework1: 1.12.*
This package is auto-updated.
Last update: 2024-09-14 00:23:55 UTC
README
ZF1 Tool Mapper model generator 是一个利用命令行和 "Data Mapper" 模板快速创建标准应用模型的工具。关于此类模型的创建,在 "Zend Framework 教程" 的 "创建模型和数据库表" 页面有详细描述。
安装
由于该工具是 Zend Framework 1.X Zend_Tool CLI 的扩展,您必须已安装并配置了 Zend_Tool CLI。如何安装和配置 Zend_Tool,请参阅 此处
Git 克隆
安装 ZF1 Tool Mapper models generator
cd <project name>/library
git clone https://github.com/vladmeh/Zftool.git
您应该获得以下项目结构
<project name>/
|-- application/
|-- library/
| |-- Zftool/
| | '-- Tool/
| | '-- Project/
| | |-- Context/
| | | '-- ZF/
| | | |-- ModelColFile.php
| | | |-- ModelMapperDirectory.php
| | | '-- ModelMapperFile.php
| | '-- Provider/
| | |-- Manifest.php
| | '-- ModelMapperProvider.php
| |--...
|-- public/
|-- ...
Zend_Tool 配置
如果您还没有这样做,请配置用于存储 .zf
和 Zend_Tool 配置文件 .zf.ini
的目录
zf --setup storage-directory
zf --setup config-file
编辑创建的配置文件 .zf.ini
php.include_path = "...;<the path to your project>/library"
autoloadernamespaces.0 = "Zftool_"
basicloader.classes.0 = "Zftool_Tool_Project_Provider_ModelMapperProvider"
basicloader.classes.1 = "Zftool_Tool_Project_Provider_Manifest"
您可以使用命令 zf show config
了解 .zf.ini
文件的位置及其当前设置
检查安装
zf ? modelmapper
您应该看到类似以下内容
Zend Framework Command Line Console Tool v1.12.13
Actions supported by provider "Modelmapper"
Modelmapper
zf create modelmapper table-name module
Note: There are specialties, use zf create modelmapper.? to get specific help on them.
Note: There are specialties, use zf show modelmapper.? to get specific help on them.
应用
主要命令
zf create modelmapper Tablename
它将为您创建数据库表 Tablename
的三个主要模型文件。
<project name>/
|-- application/
| |-- models/
| | |-- DbTable/
| | | '-- Tablename.php
| | |-- mappers/
| | | '-- Tablename.php
| | '-- Tablename.php
如果您需要在模块中创建模型
zf create modelmapper Tablename modulename
将在模块 modulename
中直接创建表 Tablename
的模型。
<project name>/
|-- application/
| |-- modules/
| | |-- modulename/
| | | |-- models/
| | | | |-- DbTable/
| | | | | '-- Tablename.php
| | | | |-- mappers/
| | | | | '-- Tablename.php
| | | | '-- Tablename.php
如果模型文件已存在,您将被提示选择重写或备份旧文件
This project already has a Mapper model: ...
Overwrite?(y) Backup old file?(a) Cancel.(n)
辅助命令
zf create modelmapper.?
Zend Framework Command Line Console Tool v1.12.13
Details for action "Create" and provider "Modelmapper"
Modelmapper
zf create modelmapper table-name module
zf create modelmapper.table-model table-name module
zf create modelmapper.mapper-model name module
zf create modelmapper.db-table name actual-table-name module
zf show modelmapper.?
Zend Framework Command Line Console Tool v1.12.13
Details for action "Show" and provider "Modelmapper"
zf show modelmapper.table-list
zf show modelmapper.column-list table-name
仅创建主模型文件 models/Tablename.php
zf create modelmapper.table-model table-name module
仅创建 Mapper 模型文件 models/mappers/Tablename.php
zf create modelmapper.mapper-model name module
仅创建 DbTable 模型 models/DbTable/Tablename.php
(类似命令 zf create db-table name actual-table-name module force-overwrite
)
zf create modelmapper.db-table name actual-table-name module force-overwrite
数据库中现有表列表
zf show modelmapper.table-list
数据库表中字段列表
zf show modelmapper.column-list table-name
许可证
版权(c)2013 VladMeh
在 MIT 许可证(MIT-LICENSE.txt)下分发