There is a module for evenrything, zend framework is a modular framework. How can I write good code?
Packaging and reuse code is an important practice for write good application.
6. PSR are your best friends!
PSR standards are the pillars
of interoperability
PHP-CS-Fixer
http://cs.sensiolabs.org/
Gianluca Arbezzano - @GianArb – https://github.com/GianArb
8. 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
9. There are different
configuration layers
module.config.php
global.php
local.php
….
Use /config/autoload directory for manage
options override!
Gianluca Arbezzano - @GianArb – https://github.com/GianArb
10. Good Implementation!
ZendDeveloperToolsModule
public function onBootstrap(EventInterface $event)
{
……
if (!$options->isEnabled()) {
return;
}
…...
$em->attachAggregate($sm->get('ZendDeveloperToolsProfilerListener'));
if ($options->isToolbarEnabled()) {
$sem->attach('profiler', $sm->get('ZendDeveloperToolsToolbarListener'), null);
…….
}
Gianluca Arbezzano - @GianArb – https://github.com/GianArb
11. 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
17. Service locator!
ServiceFactory VS Closure
Closure isn’t serializable
Module.php is more readable
Closures limit the ability to cache the cofiguration
Gianluca Arbezzano - @GianArb – https://github.com/GianArb