定制 soflomo/staging-bar 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

soflomo/staging-bar

Composer 安装命令:

composer require soflomo/staging-bar

包简介

A staging bar notification for Zend Framework 2 projects

README 文档

README

The Soflomo StagingBar is a very small Zend Framework 2 module rendering a notification bar at the top of every page. The bar is meant for staging environment to inform visitors the website is only meant for testing purposes and should not be confused with the production version.

Preview of staging bar

Installation

Add "soflomo/staging-bar" to your composer.json file and update your dependencies. Enable Soflomo\StagingBar in your local application.config.php.

If you do not have a composer.json file in the root of your project, copy the contents below and put that into a file called composer.json and save it in the root of your project:

{
    "require": {
        "soflomo/staging-bar": ">=1.0.0,<2.0.0-dev"
    }
}

Then execute the following commands in a CLI:

curl -s http://getcomposer.org/installer | php
php composer.phar install

Now you should have a vendor directory, including a soflomo/staging-bar. In your bootstrap code, make sure you include the vendor/autoload.php file to properly load the Soflomo StagingBar module.

Local application configuration

This module is the easiest to load via a local application configuration file. This means that just like "local" files in the config/autoload, you can also enable application on a local level. To achieve this, replace your application.config.php with the following file:

use Zend\Stdlib\ArrayUtils;

$config = array(
    'modules' => array(
        // Here all your global modules
    ),
    'module_listener_options' => array(
        'config_glob_paths'    => array(
            'config/autoload/{,*.}{global,local}.php',
        ),
        'module_paths' => array(
            './module',
            './vendor',
        ),
    ),
);

$local = __DIR__ . '/application.config.local.php';
if (is_readable($local)) {
    $config = ArrayUtils::merge($config, require($local));
}

return $config;

Then create a local dist file which acts as a template for all local installations, called application.config.local.php.dist:

return array(
    'modules' => array(
        // Here all your local modules
    ),
);

Then copy this dist file to remove the .dist extension. Commit the new application config and dist file into your versioning system and make sure to ignore the local application configuration.

Now you can easily enable Soflomo\StagingBar in your local application configuration without the struggle to disable it on your development or production versions.

Custom staging bar

You can override the template used to render this bar. Just create a view script that resolves to soflomo-staging-bar/partial/staging-bar.phtml and that file will be rendered. Note the bar contains some inline styles to render the bar correctly. If you override the template, it is suggested to copy these styles as well.

If you do not want to render a script with this long template name, you can use the template key in the configuration to modify the location of the template:

'soflomo_staging_bar' => array(
    'template' => 'here/your/template'
),

Custom variables

In your own template, you can inject variables to ease configuration of the bar. The variables key in the configuration is mapped to variables in the view model:

'soflomo_staging_bar' => array(
    'variables' => array('foo' => 'bar'),
),

If you call $foo in your template, it will echo bar.

统计信息

  • 总下载量: 28
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 5
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 5
  • Watchers: 4
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: BSD-3-Clause
  • 更新时间: 2013-09-17

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固