Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
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 AND
Code Reuse

Gianluca Arbezzano - @GianArb – https://github.com/GianArb
PSR are your best friends!
PSR standards are the pillars
of interoperability
PHP-CS-Fixer
http://cs.sensiolabs.org/

Gianl...
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...
There are different
configuration layers
module.config.php
global.php
local.php
….
Use /config/autoload directory for mana...
Good Implementation!
ZendDeveloperToolsModule
public function onBootstrap(EventInterface $event)
{
……
if (!$options->isEna...
How to register a module inside
your application
return array(
'modules' => array(
’Application',
’MyModule’,
…..
),
'modu...
Think abaut an
overridable
configuration
Gianluca Arbezzano - @GianArb – https://github.com/GianArb
Config
Application
'controllers' => array(
'invokables' => array(
'ApplicationControllerIndex' => 'ApplicationControllerIn...
Override views
Application

MyModule

Config:

Config:

'view_manager' => array(
'template_path_stack' => array(
__DIR__ ....
Console Usage
class Module {
public function getConsoleUsage(AdapterInterface $console)
{
return array(
array('test [--par...
Console entry point
Example
https://github.com/doctrine/DoctrineModule/tree/master/bin

Composer:
{
…,
“bin”: [
bin/consol...
Service locator!
ServiceFactory VS Closure
Closure isn’t serializable
Module.php is more readable

Closures limit the abil...
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”...
Open Source..
Why?

Gianluca Arbezzano - @GianArb – https://github.com/GianArb
Portfolio

Gianluca Arbezzano - @GianArb – https://github.com/GianArb
More
implementations
=
More BUG FIXS
and
More 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

Gianluca Arbezzano - @GianArb – https://github.com/GianArb
Upcoming SlideShare
Loading in …5
×

ZfDayIt 2014 - There is a module for everything

1,715 views

Published on

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.

Published in: Technology
  • Be the first to comment

  • Be the first to like this

ZfDayIt 2014 - There is a module for everything

  1. 1. Gianluca Arbezzano @GianArb https://github.com/GianArb Gianluca Arbezzano - @GianArb – https://github.com/GianArb
  2. 2. There is a module for everything! Gianluca Arbezzano - @GianArb – https://github.com/GianArb
  3. 3. How?! Gianluca Arbezzano - @GianArb – https://github.com/GianArb
  4. 4. Gianluca Arbezzano - @GianArb – https://github.com/GianArb
  5. 5. Packaging AND Code Reuse Gianluca Arbezzano - @GianArb – https://github.com/GianArb
  6. 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
  7. 7. Where/is/my/dir? Follow the framework tree Gianluca Arbezzano - @GianArb – https://github.com/GianArb
  8. 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. 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. 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. 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
  12. 12. Think abaut an overridable configuration Gianluca Arbezzano - @GianArb – https://github.com/GianArb
  13. 13. Config Application 'controllers' => array( 'invokables' => array( 'ApplicationControllerIndex' => 'ApplicationControllerIndexController', ), ), MyModule 'controllers' => array( 'invokables' => array( 'ApplicationControllerIndex' => ’MyModuleControllerIndexController', ), ), Gianluca Arbezzano - @GianArb – https://github.com/GianArb
  14. 14. Override views Application MyModule Config: Config: 'view_manager' => array( 'template_path_stack' => array( __DIR__ . '/../view', ), ), 'view_manager' => array( 'template_path_stack' => array( __DIR__ . '/../view', ), ), Directorty Structure: Directory Structure: view/ index/ index/ index.phtml view/ index/ index/ index.phtml Gianluca Arbezzano - @GianArb – https://github.com/GianArb
  15. 15. Console Usage class 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
  16. 16. Console entry point Example https://github.com/doctrine/DoctrineModule/tree/master/bin Composer: { …, “bin”: [ bin/console-file ], … } Gianluca Arbezzano - @GianArb – https://github.com/GianArb
  17. 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
  18. 18. Register Event to increase flexibility! Gianluca Arbezzano - @GianArb – https://github.com/GianArb
  19. 19. Aggregate & composition Gianluca Arbezzano - @GianArb – https://github.com/GianArb
  20. 20. Composer or Not Composer Both! Gianluca Arbezzano - @GianArb – https://github.com/GianArb
  21. 21. Zend Framework is modular! { “name”: “my-module/use-only-feed-component”, “description”:”Automatic feed reader”, “licence” : “MIT”, ….., “require”:[ “zend-framework/zend-framework” : “2.2.*” ], } "require": { "php": ">=5.3.3", "zendframework/zend-feed": "self.version” }, https://github.com/robertboloc/zf2-components-list-generator Gianluca Arbezzano - @GianArb – https://github.com/GianArb
  22. 22. Open Source.. Why? Gianluca Arbezzano - @GianArb – https://github.com/GianArb
  23. 23. Portfolio Gianluca Arbezzano - @GianArb – https://github.com/GianArb
  24. 24. More implementations = More BUG FIXS and More features Gianluca Arbezzano - @GianArb – https://github.com/GianArb
  25. 25. Implement your module into Zend Skeleton Application Gianluca Arbezzano - @GianArb – https://github.com/GianArb
  26. 26. Gianluca Arbezzano - @GianArb – https://github.com/GianArb
  27. 27. #IRC #zftalk #zftalk.modules Gianluca Arbezzano - @GianArb – https://github.com/GianArb
  28. 28. Test PhpUnit Gianluca Arbezzano - @GianArb – https://github.com/GianArb
  29. 29. Write Issues! help your future contributors Gianluca Arbezzano - @GianArb – https://github.com/GianArb
  30. 30. Git: handle with care! Gianluca Arbezzano - @GianArb – https://github.com/GianArb
  31. 31. README.md Gianluca Arbezzano - @GianArb – https://github.com/GianArb
  32. 32. PhpDoc ** * This is a summary. * * This is a description */ Gianluca Arbezzano - @GianArb – https://github.com/GianArb
  33. 33. Documentation Gianluca Arbezzano - @GianArb – https://github.com/GianArb
  34. 34. Some good modules Gianluca Arbezzano - @GianArb – https://github.com/GianArb
  35. 35. Some good modules Gianluca Arbezzano - @GianArb – https://github.com/GianArb
  36. 36. Some good modules Gianluca Arbezzano - @GianArb – https://github.com/GianArb
  37. 37. Modules Repository Gianluca Arbezzano - @GianArb – https://github.com/GianArb

×