flame / modules
Nette modules on the Steroids
Installs: 60 625
Dependents: 4
Suggesters: 1
Security: 0
Stars: 13
Watchers: 4
Forks: 7
Open Issues: 4
Requires
- php: >=5.3.2
- nette/nette: ~2.2
Requires (Dev)
- flame/tester: dev-master
- janmarek/mockista: dev-master
This package is not auto-updated.
Last update: 2024-12-16 16:12:32 UTC
README
#Nette Modules on the Steroids
Simple registration and management of Nette modules & extensions.
Read more on project homepage.
##Features
###Simple configuration ####config.neon In config.neon register extension Flame\Modules\DI\ModulesExtension
extensions: - Flame\Modules\DI\ModulesExtension
####Add your extensions Register extensions very simply
extensions: - App\AppModule\DI\AppExtension rest: Flame\Rest\DI\RestExtension events: Kdyby\Events\DI\EventsExtension # ... - Flame\Modules\DI\ModulesExtension # Do not forget to add it!
That's all, nothing more! Simple!
TIP! Make sure the ModulesExtension is registered as the last nette extensions. You will avoid a lot of misunderstanding.
##Examples ###IRouterProvider
class AppExtension extends CompilerExtension implements Flame\Modules\Providers\IRouterProvider { /** * Returns array of ServiceDefinition, * that will be appended to setup of router service * * @example https://github.com/nette/sandbox/blob/master/app/router/RouterFactory.php - createRouter() * @return \Nette\Application\IRouter */ public function getRoutesDefinition() { return new Nette\Application\Routers\Route('<module>/<presenter>/<action>[/<id>]', array( 'module' => 'App', 'Presenter' => 'Homepage', 'action' => 'default', 'id' => null ); } }
###NEW! You can add your separated service as your router factory
class AppExtension extends CompilerExtension { public function loadConfiguration() { $builder = $this->getContainerBuilder(); $builder->addDefinition('service.routerFactory') ->setClass('Modules\RouterFactory') // YOUR ROUTER FACTORY CLASS ->addTag(Flame\Modules\ModulesExtension::TAG_ROUTER); // DONT FORGET TO ADD THE TAG! } }
class AppExtension extends CompilerExtension implements Flame\Modules\Providers\IPresenterMappingProvider { /** * Returns array of ClassNameMask => PresenterNameMask * * @example return array('*' => 'Booking\*Module\Presenters\*Presenter'); * @return array */ public function getPresenterMapping() { return array( '*' => 'App\*Module\Presenters\*Presenter' ); } }
class AppExtension extends CompilerExtension implements Flame\Modules\Providers\IParametersProvider { /** * Return array of parameters, * which you want to add into DIC * * @example return array('images' => 'path/to/folder/with/images'); * @return array */ public function getParameters() { return array( 'images' => '%wwwDir%/path/to/folder/with/images', 'consoleMode' => true, 'appDir' => 'aa' ); } }
class HelperExtension extends CompilerExtension implements Flame\Modules\Providers\ITemplateHelpersProvider { /** * Return list of helpers definitions or providers * * @return array */ public function getHelpersConfiguration() { return array( 'App\HelperModule\Template\HelperProvider' ); } }
class MacroExtension extends CompilerExtension implements Flame\Modules\Providers\ILatteMacrosProvider { /** * Get array of latte macros classes * * @return array */ public function getLatteMacros() { return array( 'App\MacroModule\Template\MacroInstaller' ); } }
class ErrorExtension extends CompilerExtension implements Flame\Modules\Providers\IErrorPresenterProvider { /** * Return name of error presenter * * @return string */ public function getErrorPresenterName() { return 'Error:CustomError'; } }
and more: ITracyBarPanelsProvider, ITracyPanelsProvider
###What next? Look into the project homepage for more details.
Read more about this package on blog [CZE].
Based on SOLID MODULAR CONCEPT.