fredjuvaux / silex-orm-skeleton
为Silex微框架预配置的骨架,包含doctrine ORM和bootstrap配置。
dev-master / 1.1.x-dev
2015-08-18 17:34 UTC
Requires
- php: >=5.3.3
- fredjuvaux/doctrine-orm-provider: 1.0.*@dev
- fredjuvaux/silex-less-provider: dev-master
- silex/silex: ~1.0
- silex/web-profiler: ~1.0
- symfony/browser-kit: ~2.3
- symfony/class-loader: ~2.3
- symfony/config: ~2.3
- symfony/console: ~2.3
- symfony/css-selector: ~2.3
- symfony/debug: ~2.3
- symfony/finder: ~2.3
- symfony/form: 2.5.2
- symfony/monolog-bridge: ~2.3
- symfony/process: ~2.3
- symfony/security: ~2.3
- symfony/translation: ~2.3
- symfony/twig-bridge: ~2.3
- symfony/validator: 2.5.2
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}