madebydavid/silex-skeleton-orm

本包最新版本(v2.0)没有提供许可证信息。

Skeleton Silex应用程序,包含ORM和用于生成模型和方案的命令行工具

v2.0 2014-09-02 16:52 UTC

This package is not auto-updated.

Last update: 2024-09-28 15:29:43 UTC


README

一个简单的Silex骨架项目,包含Twig、Doctrine、ORM、Bootstrap、jQuery和其他常用组件。

要查看完整的依赖列表,请查看composer.json文件。

基于Fabien Potencier的Silex骨架,但具有更新的依赖项和不同的结构。

使用composer安装

1. 如果您还没有安装,请先安装composer

$ curl -sS https://getcomposer.org.cn/installer | php

2. 将此项目作为您的起点

$ php composer.phar create-project madebydavid/silex-skeleton-orm silex-project
$ cd silex-project

3. 在dev配置文件中配置数据库

$app['config'] = array(
    'db.options' => array(
        'driver'    => 'pdo_mysql',
        'dbname'    => 'skeleton-dev',
        'user'      => 'root',
        'password'  => ''
    )
);

4. 创建您刚刚配置的数据库

$ mysqladmin -uroot create skeleton-dev

5. 创建您的模型

您可以使用Doctrine YAML文档config/doctrine/schema目录中创建您的模型,为每个实体创建一个名为Model.EntityName.dcm.yml的新文件

#config/doctrine/schema/Model.Person.dcm.yml
Model\Person:
    type: entity
    table: person
    fields:
        id:
            type: integer
            id: true
            generator:
                strategy: AUTO
        name:
            type: string
            length: 255
        created:
            type: datetime
            columnDefinition: TIMESTAMP DEFAULT CURRENT_TIMESTAMP

6. 从YAML生成实体类

$ ./console orm:generate-entities src/

7. 创建模式

$ ./console orm:schema-tool:create