modette / cache-generator
Generate your Latte templates and DI containers cache with single command.
This package has no released version yet, and little information is available.
README
Generate your Latte templates and DI containers cache with single command.
Installation
The best way to install modette/cache-generator is using Composer:
$ composer require modette/cache-generator
Register in your config.neon
:
extensions: cacheGenerator: Modette\CacheGenerator\DI\CacheGeneratorExtension
Configuration
DI containers generator
Modify last lines of bootstrap.php
$configurator->addServices(['configurator' => $configurator]); // we need Configurator available as a service $container = $configurator->createContainer(); return $container;
Following example is configured to generate 3 containers (debug
, production
and console
) which differs in consoleMode
and debugMode
parameters.
You don't need to add productionMode
parameter for Nette BC, it is done automatically.
Default configuration expects that you run console in debug mode only.
Warning It is possible that same packages are incompatible. Requirement is to use parameter debugMode instead of PHP_SAPI in all CompilerExtensions.
cacheGenerator: generators: diContainers: Modette\CacheGenerator\Generators\DiContainersCacheGenerator( [ debug: [debugMode: true, consoleMode: false], production: [debugMode: false, consoleMode: false], console: [debugMode: true, consoleMode: true] ], "?->getService('configurator')"(@container) )
Latte templates cache generator
cacheGenerator: generators: latteTemplates: Modette\CacheGenerator\Generators\LatteTemplatesCacheGenerator( [%appDir%], "?->createTemplate()"(@latte.templateFactory) )
Usage - via CLI
Run command in Symfony console
$ cache:generate
Add -v
parameter to display more detailed informations
Usage - direct
<?php // get Modette\CacheGenerator\CacheGenerator from DI container $generator->generate(new \Symfony\Component\Console\Output\NullOutput());
Creating your own generators
Implement IGenerator
and register it in generators list
<?php class YourGenerator implements \Modette\CacheGenerator\Generators\IGenerator { public function generate(\Symfony\Component\Console\Output\OutputInterface $output): void { // generate cache // inform about it in console } }
What next?
Generate OpCode cache with fantastic Composer plugin composer-warmup
Repository of package: https://github.com/modette/cache-generator.