Date post: | 29-Jan-2015 |
Category: |
Technology |
Upload: | gianluca-arbezzano |
View: | 103 times |
Download: | 0 times |
Gianluca Arbezzano - @GianArb – https://github.com/GianArb
Gianluca Arbezzano@GianArb
https://github.com/GianArb
Gianluca Arbezzano - @GianArb – https://github.com/GianArb
There is a module for everything!
Gianluca Arbezzano - @GianArb – https://github.com/GianArb
How?!
Gianluca Arbezzano - @GianArb – https://github.com/GianArb
Gianluca Arbezzano - @GianArb – https://github.com/GianArb
Packaging ANDCode Reuse
Gianluca Arbezzano - @GianArb – https://github.com/GianArb
PSR are your best friends!
PHP-CS-Fixerhttp://cs.sensiolabs.org/
PSR standards are the pillarsof interoperability
Gianluca Arbezzano - @GianArb – https://github.com/GianArb
Where/is/my/dir?
Follow the framework tree
Gianluca Arbezzano - @GianArb – https://github.com/GianArb
Configuration is necessary..• Do not overdo• Don’t be lazy• Choose pertinent index names• User namespace
• Set default values
Gianluca Arbezzano - @GianArb – https://github.com/GianArb
There are different configuration layers
module.config.phpglobal.phplocal.php….
Use /config/autoload directory for manageoptions override!
Gianluca Arbezzano - @GianArb – https://github.com/GianArb
Good Implementation!
ZendDeveloperTools\Modulepublic function onBootstrap(EventInterface $event) {
…… if (!$options->isEnabled()) { return; } …... $em->attachAggregate($sm->get('ZendDeveloperTools\ProfilerListener')); if ($options->isToolbarEnabled()) { $sem->attach('profiler', $sm->get('ZendDeveloperTools\ToolbarListener'), null); ……. }
Gianluca Arbezzano - @GianArb – https://github.com/GianArb
How to register a module inside your application
return array( 'modules' => array( ’Application', ’MyModule’,
….. ), 'module_listener_options' => array( 'config_glob_paths' => array( 'config/autoload/{,*.}{global,local}.php', ), 'module_paths' => array( './module', './vendor', ), ),);
Gianluca Arbezzano - @GianArb – https://github.com/GianArb
Think abaut an overridable
configuration
Gianluca Arbezzano - @GianArb – https://github.com/GianArb
ConfigApplication'controllers' => array( 'invokables' => array( 'Application\Controller\Index' => 'Application\Controller\IndexController', ),),
MyModule'controllers' => array( 'invokables' => array( 'Application\Controller\Index' => ’MyModule\Controller\IndexController', ),),
Gianluca Arbezzano - @GianArb – https://github.com/GianArb
Override viewsApplicationConfig:'view_manager' => array( 'template_path_stack' => array( __DIR__ . '/../view', ),),
Directorty Structure:view/ index/ index/ index.phtml
MyModuleConfig:'view_manager' => array( 'template_path_stack' => array( __DIR__ . '/../view', ),),
Directory Structure:view/ index/ index/ index.phtml
Gianluca Arbezzano - @GianArb – https://github.com/GianArb
Console Usageclass Module {
public function getConsoleUsage(AdapterInterface $console) {
return array( array('test [--params=]', 'Description of test command’),array('run ', 'Start anction')
); }
}
Gianluca Arbezzano - @GianArb – https://github.com/GianArb
Console entry point
Examplehttps://github.com/doctrine/DoctrineModule/tree/master/bin
Composer:
{…,“bin”: [
bin/console-file],…
}
Gianluca Arbezzano - @GianArb – https://github.com/GianArb
Service locator!
ServiceFactory VS ClosureClosure isn’t serializable
Module.php is more readable
Closures limit the ability to cache the cofiguration
Gianluca Arbezzano - @GianArb – https://github.com/GianArb
Register Event to increase flexibility!
Gianluca Arbezzano - @GianArb – https://github.com/GianArb
Aggregate & composition
Gianluca Arbezzano - @GianArb – https://github.com/GianArb
Composer or Not Composer
Both!
Gianluca Arbezzano - @GianArb – https://github.com/GianArb
Zend Framework is modular!{
“name”: “my-module/use-only-feed-component”,“description”:”Automatic feed reader”,“licence” : “MIT”,…..,“require”:[
“zend-framework/zend-framework” : “2.2.*”],
}
https://github.com/robertboloc/zf2-components-list-generator
"require": { "php": ">=5.3.3", "zendframework/zend-feed": "self.version”},
Gianluca Arbezzano - @GianArb – https://github.com/GianArb
Open Source.. Why?
Gianluca Arbezzano - @GianArb – https://github.com/GianArb
Portfolio
Gianluca Arbezzano - @GianArb – https://github.com/GianArb
More implementations
= More BUG FIXS
andMore features
Gianluca Arbezzano - @GianArb – https://github.com/GianArb
Implement your module into Zend Skeleton Application
Gianluca Arbezzano - @GianArb – https://github.com/GianArb
Gianluca Arbezzano - @GianArb – https://github.com/GianArb
#IRC
#zftalk
#zftalk.modules
Gianluca Arbezzano - @GianArb – https://github.com/GianArb
Test PhpUnit
Gianluca Arbezzano - @GianArb – https://github.com/GianArb
Write Issues! help your future contributors
Gianluca Arbezzano - @GianArb – https://github.com/GianArb
Git: handle with care!
Gianluca Arbezzano - @GianArb – https://github.com/GianArb
README.md
Gianluca Arbezzano - @GianArb – https://github.com/GianArb
PhpDoc** * This is a summary. * * This is a description */
Gianluca Arbezzano - @GianArb – https://github.com/GianArb
Documentation
Gianluca Arbezzano - @GianArb – https://github.com/GianArb
Some good modules
Gianluca Arbezzano - @GianArb – https://github.com/GianArb
Some good modules
Gianluca Arbezzano - @GianArb – https://github.com/GianArb
Some good modules
Gianluca Arbezzano - @GianArb – https://github.com/GianArb
Modules Repository