websafe/lib-view-helper-git-repository

一个用于获取当前应用程序本地Git仓库信息的ZF2视图辅助库。

0.1.0 2014-03-05 23:23 UTC

This package is not auto-updated.

Last update: 2024-09-14 15:17:12 UTC


README

一个用于获取当前应用程序本地ZF2 - 视图辅助库Git仓库信息的库。

快速入门

将此包添加到您的基于Composer的应用程序中

composer.json中添加此包,并运行以在vendor/中安装:

composer require \
    websafe/lib-view-helper-git-repository:0.1.*

php vendor/bin/composer.phar require \
    websafe/lib-view-helper-git-repository:0.1.*

在您的ZF2应用程序中启用提供的视图辅助库

要启用您的应用程序中提供的视图辅助库,请将位于config/autoload/websafe.view.helper.git.repository.global.php的文件websafe.view.helper.git.repository.global.php.distvendor/websafe/lib-view-helper-git-repository/config/复制。

复制的文件声明了您的ZF2应用程序中提供的视图辅助库所需的可调用对象

return array(
    'view_helpers' => array(
        'invokables' => array(
            'gitRepoCurrentBranch'
                => 'Websafe\View\Helper\Git\Repository\CurrentBranch',
            'gitRepoDescription'
                => 'Websafe\View\Helper\Git\Repository\Description',
        ),
    ),
);

在您的视图脚本中使用提供的视图辅助库

Websafe\View\Helper\Git\Repository\CurrentBranch

<h1><?php echo $this->gitRepoCurrentBranch();?></h1>

结果

<h1>master</h1>

Websafe\View\Helper\Git\Repository\Description

<p><?php echo $this->gitRepoDescription();?><p>

结果

<p>Unnamed repository; edit this file 'description' to name the repository.</p>