caxy / annotation-bundle
Annotator(http://okfnlabs.org/annotator/)的实现
dev-master
2015-06-23 19:39 UTC
Requires
- php: >=5.3.3
- doctrine/orm: ~2.3
- symfony/framework-bundle: ~2.1
- twig/extensions: ~1.2
This package is auto-updated.
Last update: 2024-09-22 06:50:49 UTC
README
Annotator (http://okfnlabs.org/annotator/)的实现
先决条件
此版本的包需要Symfony 2.2,jQuery和Doctrine。
安装
- 使用composer下载CaxyAnnotationBundle
- 启用Bundle
- 配置CaxyAnnotationBundle
- 导入CaxyAnnotationBundle的路由
- 更新你的数据库模式
- 在需要的页面上初始化CaxyAnnotation
步骤1:使用composer下载CaxyAnnotationBundle
在composer.json中添加CaxyAnnotationBundle
{ "require": { "caxy/annotation-bundle": "dev-master" } }
现在通过运行以下命令告诉composer下载bundle
$ php composer.phar update caxy/annotation-bundle
Composer会将bundle安装到项目的vendor/caxy
目录。
步骤2:启用Bundle
在kernel中启用bundle
<?php // app/AppKernel.php public function registerBundles() { $bundles = array( // ... new Caxy\AnnotationBundle\CaxyAnnotationBundle(), ); }
步骤3:配置CaxyAnnotationBundle
app/config/caxy/annotation.yml
caxy_annotation: selector: ".annotation" plugins: ['store']
- plugins是可选的,目前只支持store插件
步骤4:导入CaxyAnnotationBundle路由文件
导入注释的配置文件
# app/config/config.yml - { resource: caxy/annotation.yml }
然后导入CaxyAnnotationBundle路由文件。
在YAML中
# app/config/routing.yml caxy_annotation: resource: "@CaxyAnnotationBundle/Resources/config/routing/routing.yml"
步骤5:更新你的数据库模式
- 如果你使用的是store插件,则需要更新你的模式。如果不使用,请跳到步骤6。
现在bundle已配置,最后需要更新数据库模式。
对于ORM,运行以下命令。
$ php app/console doctrine:schema:update --force
步骤6:在需要的页面上初始化CaxyAnnotation。
现在CaxyAnnotationBundle已启用并配置,您可以通过在任意twig视图中添加以下内容来使用它
{{ annotation_init() }}
并添加一个html容器,选择器已在步骤3中配置,例如
- 如果使用在配置中启用的store插件,可以添加并传递自定义元数据
- 例如:{{ annotation_init({'metadata': {'productId': 11}}) }}