fredjuvaux/silex-orm-skeleton

为Silex微框架预配置的骨架,包含doctrine ORM和bootstrap配置。

安装: 9

依赖者: 0

建议者: 0

安全: 0

星标: 15

关注者: 2

分支: 6

开放问题: 2

语言:HTML

类型:项目

dev-master / 1.1.x-dev 2015-08-18 17:34 UTC

This package is not auto-updated.

Last update: 2024-09-28 15:18:46 UTC


README

Silex骨架,包含doctrine ORM、bootstrap和CRUD示例。

有关doctrine文档,请参阅symfony和doctrine文档。

安装

cd /path/to/your_project
git clone git@github.com:fredjuvaux/silex-orm-skeleton.git

安装Composer

curl -s https://getcomposer.org/installer | php

有关Composer的更多信息,请访问getcomposer.org

并安装您的依赖项

php composer.phar install

在src/app.php中设置您的数据库信息

$app->register(new DoctrineServiceProvider(), array(
    'db.options' => array(
        'driver'        => 'pdo_mysql',
        'host'          => 'localhost',
        'dbname'        => 'xxx',
        'user'          => 'xxx',
        'password'      => 'xxx',
    ),
));

创建数据库,然后使用CLI工具生成表(以acme演示为例)

php bin/console orm:schema-tool:update --force

可用的命令

php bin/console --info
Available commands:
  help                             Displays help for a command
  list                             Lists commands
dbal
  dbal:import                      Import SQL file(s) directly to Database.
  dbal:reserved-words              Checks if the current database contains identifiers that are reserved.
  dbal:run-sql                     Executes arbitrary SQL directly from the command line.
orm
  orm:clear-cache:metadata         Clear all metadata cache of the various cache drivers.
  orm:clear-cache:query            Clear all query cache of the various cache drivers.
  orm:clear-cache:result           Clear result cache of the various cache drivers.
  orm:convert-d1-schema            Converts Doctrine 1.X schema into a Doctrine 2.X schema.
  orm:convert-mapping              Convert mapping information between supported formats.
  orm:ensure-production-settings   Verify that Doctrine is properly configured for a production environment.
  orm:generate-entities            Generate entity classes and method stubs from your mapping information.
  orm:generate-proxies             Generates proxy classes for entity classes.
  orm:generate-repositories        Generate repository classes from your mapping information.
  orm:info                         Show basic information about all mapped entities
  orm:run-dql                      Executes arbitrary DQL directly from the command line.
  orm:schema-tool:create           Processes the schema and either create it directly on EntityManager Storage Connection or generate the SQL output.
  orm:schema-tool:drop             Drop the complete database schema of EntityManager Storage Connection or generate the corresponding SQL output.
  orm:schema-tool:update           Executes (or dumps) the SQL needed to update the database schema to match the current mapping metadata.
  orm:validate-schema              Validate that the mapping files.

示例

php bin/console orm:generate-entities src

Acme CRUD演示路由

/path/to/your_project/acme/
/path/to/your_project/acme/create
/path/to/your_project/acme/show/{id}
/path/to/your_project/acme/update/{id}
/path/to/your_project/acme/delete/{id}