2017 © Pedro PelΓ‘ez
 

library maintenance-screen

The "Maintenance mode" screen library

image

progminer/maintenance-screen

The "Maintenance mode" screen library

  • Sunday, July 22, 2018
  • by ProgMiner
  • Repository
  • 1 Watchers
  • 0 Stars
  • 42 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 11 Versions
  • 17 % Grown

The README.md

maintenance-screen

Latest Version on Packagist ![Software License][ico-license] Build Status Code Coverage Scrutinizer Code Quality ![Total Downloads][ico-downloads], (*1)

The "Maintenance mode" screen library, (*2)

Install

Via Composer, (*3)

``` bash composer require progminer/maintenance-screen, (*4)


For using some included classes you also need to install more requrements: - For `MaintenanceScreen\FileLoader\YamlFileLoader` - [Symfony Yaml](http://symfony.com/doc/current/components/yaml): ```bash composer require symfony/yaml ^4.0
  • For ProgMinerUtils\TemplateRenderer\TwigTemplateRenderer - Twig:
composer require twig/twig ^2.4

Usage

An instance of MaintenanceScreen\MaintenanceScreen consists of configurations array, MaintenanceScreen\TranslatorProvider\TranslatorProviderInterface instance and ProgMinerUtils\TemplateRenderer\TemplateRendererInterface instance., (*5)

This example step by step illustrates how works with the MaintenanceScreen\MaintenanceScreen., (*6)

Example

In first order you have to write uses, include a vendor/autoload.php (ommited), etc. Also you could make configuration array for MaintenanceScreen\MaintenanceScreen., (*7)

use MaintenanceScreen\ConfigurationLoader;
use MaintenanceScreen\MaintenanceScreen;

use MaintenanceScreen\TranslatorProvider\ArrayTranslatorProvider;

use ProgMinerUtils\TemplateRenderer\CallableTemplateRenderer;

$config = [
    'template_name'    => 'Default', // template name, not required
    'default_language' => 'en',      // uses if Accept-Language is not provided, not required
    'charset'          => 'utf-8'    // not required, charset for Response and TemplateRenderer
];

Here you have to make MaintenanceScreen\TranslatorProvider\TranslatorProviderInterface instance and you have two included methods: - Use translations from array (MaintenanceScreen\TranslatorProvider\ArrayTranslatorProvider class) - Use translations from config files (MaintenanceScreen\TranslatorProvider\FilesystemTranslatorProvider class), (*8)

A simple example for first method here:, (*9)

$translatorsProvider = new ArrayTranslatorProvider([
    'en' => ['title' => 'Site in maintenance mode', 'text' => 'Site in maintenance mode'],
    'ru' => ['title' => 'Π‘Π°ΠΉΡ‚ Π² Ρ€Π΅ΠΆΠΈΠΌΠ΅ тСхобслуТивания', 'text' => 'Π‘Π°ΠΉΡ‚ Π² Ρ€Π΅ΠΆΠΈΠΌΠ΅ тСхобслуТивания']
]);

Also you can create class that implements MaintenanceScreen\TranslatorProvider\ITranslatorProvider., (*10)

Now you have to make a ProgMinerUtils\TemplateRenderer\TemplateRendererInterface instance, for example, ProgMinerUtils\TemplateRenderer\CallableTemplateRenderer:, (*11)

$templateRenderer = new CallableTemplateRenderer([
    'Default' => function($vars) { ?>

<html lang="<?=$vars['lang']?>">
    <head><title><?=$vars['title']?></title></head>
    <body><h1><center><?=$vars['text']?></center></h1></body>
</html>

    <?php }
]);

And, finally, MaintenanceScreen\MaintenanceScreen instance:, (*12)

$maintenanceScreen = new MaintenanceScreen($config, $translatorProvider, $templateRenderer);

When you have an instance of MaintenanceScreen\MaintenanceScreen you can render and/or send rendered Symfony\Component\HttpFoundation\Response:, (*13)

  • Rendering:
$response = $maintenanceScreen->render();
  • Sending:
$maintenanceScreen->send();

Both methods have not required argument $request - instance of class Symfony\Component\HttpFoundation\Request. If it is not provided this methods calls a Symfony\Component\HttpFoundation\Request::createFromGlobals method for getting current request., (*14)

Todo

  • Add more file loaders

Contributing

Please see CONTRIBUTING for details., (*15)

Security

If you discover any security related issues, please email eridan200@mail.ru instead of using the issue tracker., (*16)

Credits

API Documentation

This projects API documentation is built using Sami and available at https://progminer.github.io/maintenance-screen/master/., (*17)

Build

In order to build the documentation first get Sami as a phar file:, (*18)

# curl -O http://get.sensiolabs.org/sami.phar
composer install-sami

Next build the documentation:, (*19)

# php sami.phar update sami-config.php
composer regen-docs

The API Documentation will be generated into the docs folder. If you would like to preview it locally you can easily do so with the built-in PHP server:, (*20)

php -S 127.0.0.1:3000 -t docs

Then visit http://localhost:3000/master/ to view., (*21)

License

The MIT License (MIT). Please see License File for more information., (*22)

The Versions

22/07 2018

dev-master

9999999-dev

The "Maintenance mode" screen library

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar ProgMiner
by Eridan Domoratskiy

10/07 2018

v4.0.1

4.0.1.0

The "Maintenance mode" screen library

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar ProgMiner

10/07 2018

v4.0

4.0.0.0

The "Maintenance mode" screen library

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar ProgMiner

01/03 2018

v3.0.1

3.0.1.0

The "Maintenance mode" screen library

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar ProgMiner

27/02 2018

v3.0

3.0.0.0

The "Maintenance mode" screen library

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar ProgMiner

24/02 2018

v2.0

2.0.0.0

The "Maintenance mode" screen library

  Sources   Download

MIT

The Requires

 

by Avatar ProgMiner

24/02 2018

v1.3

1.3.0.0

The "Maintenance mode" screen for your site

  Sources   Download

MIT

The Requires

 

by Avatar ProgMiner

24/02 2018

v1.2

1.2.0.0

The "Maintenance mode" screen for your site

  Sources   Download

MIT

The Requires

 

by Avatar ProgMiner

23/02 2018

v1.1

1.1.0.0

The "Maintenance mode" screen for your site

  Sources   Download

MIT

The Requires

 

by Avatar ProgMiner

23/02 2018

v1.0.1

1.0.1.0

The "Maintenance mode" screen for your site

  Sources   Download

MIT

The Requires

 

by Avatar ProgMiner

23/02 2018

v1.0

1.0.0.0

The Maintenance screen for your site

  Sources   Download

MIT

The Requires

 

by Avatar ProgMiner