leaseweb / version-information-bundle
将SVN和Git 'status'命令的输出添加到Web调试工具栏
Requires
- php: >=5.3.2
- symfony/framework-bundle: ~2.1
- symfony/process: ~2.1
- symfony/security-bundle: ~2.1
Requires (Dev)
- doctrine/doctrine-bundle: *
- swiftmailer/swiftmailer: *
- symfony/validator: 2.1.*
- symfony/yaml: 2.1.*
- twig/twig: *
- willdurand/propel-typehintable-behavior: dev-master
README
测试人员如何知道他们正在测试我们应用程序的哪个修订版本以及他们正在测试哪个分支或标签?这在接受测试中尤其成问题,因为在接受测试中,会测试各个系统之间的交互。由于测试人员没有访问运行接受环境的Linux机器上的命令行权限,他们不能像开发者那样简单地执行“svn info”和“svn status”(或“git log -1”和“git status”)命令。
阅读LeaseWebLabs关于LswVersionInformationBundle的博客
为了解决这个问题,我们编写了一个名为LswVersionInformationBundle的Symfony组件。它在Symfony2调试工具栏的标签中显示了“svn info”和“svn status”(或“git log -1”和“git status”)命令的输出。实际上,这个组件是我们一年前编写的Symfony1 "lwTestingInformationPlugin"的重写,可以在下面的链接中找到。
安装
要使用Composer安装LswVersionInformationBundle,只需将以下内容添加到您的'composer.json'文件中
{
require: {
"leaseweb/version-information-bundle": "*",
...
}
}
接下来,您应该执行以下命令来安装组件
php composer.phar update leaseweb/version-information-bundle
最后,将组件添加到'app/AppKernel.php'文件中的AppKernel类的registerBundles函数中
<?php // app/AppKernel.php public function registerBundles() { ... if (in_array($this->getEnvironment(), array('dev', 'test'))) { ... $bundles[] = new Lsw\VersionInformationBundle\LswVersionInformationBundle(); } }
现在,Subversion(或Git)信息应该会显示在调试工具栏中的小“svn”(或“Git”)图标中。
配置
如果您在Symfony2应用程序中使用了自定义文件夹结构,您必须修改您的root_dir
参数。否则,collector
将无法定位您的vcs文件夹。
在您的config.yml
(如果您只为开发环境启用了组件,请使用config_dev.yml
代替)
# LSW Version Information configuration
lsw_version_information:
root_dir: path/to/your/root
所有默认值下的可用选项
# LSW Version Information configuration
lsw_version_information:
root_dir: %kernel.root_dir%/../
settings:
show_icon: true
show_current_branch: true
show_latest_revision: false
show_dirty_files: true
collectors:
hg: Lsw\VersionInformationBundle\DataCollector\HgRevisionInformationCollector
git: Acme\DemoBundle\DataCollector\MyOwnGitCollectorImplementation # This is how to override the default git implementation
注册额外的收集器
可以通过collectors
配置(见上方)注册额外的收集器。收集器必须实现类Lsw\VersionInformationBundle\RevisionInformation\RevisionInformationCollectorInterface
。
同样,您可以通过指定收集器键为git
或svn
来覆盖默认的git
和svn
收集器。