nathiss / quote-generator-bundle
一个用于生成引文的简单Symfony 2|3 扩展包。
v1.0.3
2016-09-24 14:09 UTC
Requires
- php: >=5.3.0
- symfony/framework-bundle: ~2.0|~3.0
Requires (Dev)
This package is not auto-updated.
Last update: 2024-09-14 20:30:30 UTC
README
一个用于生成引文的简单Symfony 2|3 扩展包。
安装
步骤 1. 安装
打开命令行,进入你的项目目录,执行以下命令以下载最新稳定版本
$ composer require nathiss/quote-generator-bundle
步骤 2. 启用扩展包
通过将扩展包添加到app/AppKernel.php
文件中的已注册扩展包列表中来启用扩展包
<?php // app/AppKernel.php // ... class AppKernel extends Kernel { public function registerBundles() { $bundles = array( // ... new Nathiss\Bundle\QuoteGeneratorBundle\NathissQuoteGeneratorBundle(), // ... ); // ... } // ... }
步骤 3. 更新数据库模式
要更新模式,请输入以下命令
$ ./bin/console doctrine:schema:update --force
步骤 4. 配置(可选)
您可以通过将以下行添加到您的app/config/config.yml
文件来覆盖默认模板
nathiss_quote_generate: template: 'path/to/your/template.html.twig'
默认:NathissQuoteGeneratorBundle:Default:quote.html.twig
步骤 5. 加载固定数据(可选)
要加载固定数据,请输入以下命令
$ ./bin/console doctrine:fixtures:load
(提示:如果您希望不在数据库中删除数据,请添加--append
选项)
使用方法
在您的twig模板内部执行generate_quote()
函数
{# ... #} {{ generate_quote() }} {# ... #}
将呈现为
{# ... #} <blockquote class="nathiss-quote"> <p>Some quote</p> <span class="nathiss-quote-author">Some author</span> </blockquote> {# ... #}
许可证
查看许可证文件。