SlideShare a Scribd company logo
ZF2 Asset management
                     with AssetManager module




http://www.mvassociati.it/en/gems/php/asset-management-zend-framework-2
MODULE’S ASSETS:
           IMAGES/JS/CSS




http://www.flickr.com/photos/tracyleephoto/8322509672
Shared between modules
    Like javascript libraries, logos, buttons,
    CSS scripts and snippets, etc.




3
Shared between modules
    Like javascript libraries, logos, buttons,
    CSS scripts and snippets, etc.

    Where should they be placed?




4
Shared between modules
    Like javascript libraries, logos, buttons,
    CSS scripts and snippets, etc.

    Where should they be placed?
    Inside project /public folder?
    There is a better way…




5
Exclusive of a module
    Like javascript libraries, images and
    CSS files that are needed by a single
    module only




6
Exclusive of a module
    Like javascript libraries, images and
    CSS files that are needed by a single
    module only

    Where should they be placed?




7
Exclusive of a module
    Like javascript libraries, images and
    CSS files that are needed by a single
    module only

    Where should they be placed?
    Inside that module!




8
Possible approaches
    •   Copy & paste of each file inside project
        /public folder?
    •   Use symlinks?
    •   Tune apache to "look" the files inside
        each module?




9
The way to go: AssetManager




10
AssetManager
module            Resolvers




         Assets
                   Asset      Filters
                  Manager




                   Cache




11
AssetManager
module                        Resolvers




                  Assets
                              Asset
                             Manager



Resolvers:
allowing to define asset naming and locations


12
AssetManager
module                      Resolvers




                 Assets
                            Asset       Filters
                           Manager



Filters:
allowing to make some processing
before serving assets

13
AssetManager
module                    Resolvers




                 Assets
                           Asset      Filters
                          Manager



Cache:
allowing to choose         Cache

caching policy

14
Where to put module assets?


                  all module’s
                      assets




15
module.config.php
return array(
  'asset_manager' => array(
    'resolver_configs' => array(
      'paths' => array(
        __DIR__ . '/../assets',
      ),
),),), ...
module.config.php
return array(
  'asset_manager' => array(
    'resolver_configs' => array(
      'paths' => array(
        __DIR__ . '/../assets',
      ),
),),), ...




              layout.php
              echo $this->headLink()
                   ->prependStylesheet($this->basePath() .
                                       '/css/aCssFile.css');
module.config.php
return array(
'asset_manager' => array(
  'resolver_configs' => array(
    'map' => array(
       'css/main.css' => __DIR__.'/../assets/css/main.css',
       'css/custom1.css' => __DIR__.'/../assets/css/custom1.css',
    ),
    'collections' => array(
       'css/merge.css' => array( 'css/main.css','css/custom1.css',
),),),),), ...
module.config.php
return array(
'asset_manager' => array(
  'resolver_configs' => array(
    'map' => array(
       'css/main.css' => __DIR__.'/../assets/css/main.css',
       'css/custom1.css' => __DIR__.'/../assets/css/custom1.css',
    ),
    'collections' => array(
       'css/merge.css' => array( 'css/main.css','css/custom1.css',
),),),),), ...



                layout.php
                echo $this->headLink()
                     ->prependStylesheet($this->basePath() .
                                         '/css/merge.css');
Stefano Valle
@stefanovalle
s.valle@mvassociati.it

More Related Content

PDF
Instant ACLs with Zend Framework 2
PDF
Zend Framework 2 - Basic Components
PPT
Zend Framework 2
PPTX
uRequire@greecejs: An introduction to http://uRequire.org
PDF
Staying Sane with Drupal (A Develper's Survival Guide)
PDF
Heroku pop-behind-the-sense
PPT
JavaScript Modules in Practice
PDF
Backbone js
Instant ACLs with Zend Framework 2
Zend Framework 2 - Basic Components
Zend Framework 2
uRequire@greecejs: An introduction to http://uRequire.org
Staying Sane with Drupal (A Develper's Survival Guide)
Heroku pop-behind-the-sense
JavaScript Modules in Practice
Backbone js

What's hot (20)

PPT
An Introduction to Drupal
PPTX
Vue business first
PDF
14 mvc
PDF
Web internship Yii Framework
PDF
Asynchronous Module Definition (AMD)
PDF
The Naked Bundle - Tryout
PDF
Whmcs addon module docs
PDF
Zero-config JavaScript apps with RaveJS -- SVCC fall 2014
PDF
Drupal 8, Where Did the Code Go? From Info Hook to Plugin
PDF
No Coding Necessary: Building User Macros and Dynamic Reports Inside Confluen...
DOC
No Coding Necessary: Building Confluence User Macros Cheat Sheet - Atlassian ...
ODP
Single Page Applications in Drupal
PDF
DDD, Rails and persistence
PPTX
Testing nodejs apps
PDF
What's New In Apache Lenya 1.4
PDF
JavaOne India 2011 - Servlets 3.0
PPTX
IndexedDB - Querying and Performance
PDF
232 deview2013 oss를활용한분산아키텍처구현
PDF
Servlets 3.0 - Asynchronous, Extensibility, Ease-of-use @ JavaOne Brazil 2010
PPTX
Planbox Backbone MVC
An Introduction to Drupal
Vue business first
14 mvc
Web internship Yii Framework
Asynchronous Module Definition (AMD)
The Naked Bundle - Tryout
Whmcs addon module docs
Zero-config JavaScript apps with RaveJS -- SVCC fall 2014
Drupal 8, Where Did the Code Go? From Info Hook to Plugin
No Coding Necessary: Building User Macros and Dynamic Reports Inside Confluen...
No Coding Necessary: Building Confluence User Macros Cheat Sheet - Atlassian ...
Single Page Applications in Drupal
DDD, Rails and persistence
Testing nodejs apps
What's New In Apache Lenya 1.4
JavaOne India 2011 - Servlets 3.0
IndexedDB - Querying and Performance
232 deview2013 oss를활용한분산아키텍처구현
Servlets 3.0 - Asynchronous, Extensibility, Ease-of-use @ JavaOne Brazil 2010
Planbox Backbone MVC
Ad

Viewers also liked (12)

PPS
Implementing access control with zend framework
PPT
Zend Framework 2 - PHPUnit
PDF
Error Reporting in ZF2: form messages, custom error pages, logging
PDF
Unit testing PHP apps with PHPUnit
PDF
Into the ZF2 Service Manager
PDF
Zend Framework 2 : Dependency Injection
PDF
PHPUnit best practices presentation
PDF
Clean Unit Test Patterns
ODP
Creating fast, dynamic ACLs in Zend Framework (Zend Webinar)
PPTX
Understanding Unit Testing
PDF
Introduction to Unit Testing with PHPUnit
PPTX
Unit Testing Concepts and Best Practices
Implementing access control with zend framework
Zend Framework 2 - PHPUnit
Error Reporting in ZF2: form messages, custom error pages, logging
Unit testing PHP apps with PHPUnit
Into the ZF2 Service Manager
Zend Framework 2 : Dependency Injection
PHPUnit best practices presentation
Clean Unit Test Patterns
Creating fast, dynamic ACLs in Zend Framework (Zend Webinar)
Understanding Unit Testing
Introduction to Unit Testing with PHPUnit
Unit Testing Concepts and Best Practices
Ad

Similar to Asset management with Zend Framework 2 (20)

PDF
The new static resources framework
PDF
Anatomy of a reusable module
PDF
Drupal 7 Theming - Behind the scenes
PDF
Kharkivpy#3: Javascript and Python backend
ODP
Built-in query caching for all PHP MySQL extensions/APIs
PPTX
Drupal Camp Porto - Developing with Drupal: First Steps
PPTX
Introduction And Basics of Modules in Drupal 7
PDF
Extending and Customizing Open Atrium
PPTX
Backbonejs for beginners
PDF
Doctrine 2
PPTX
Magento 2.0: Prepare yourself for a new way of module development
PDF
Introducing Assetic: Asset Management for PHP 5.3
PPTX
MUC - Moodle Universal Cache
PDF
Alfredo-PUMEX
PDF
Alfredo-PUMEX
PDF
Alfredo-PUMEX
PDF
Alfredo-PUMEX
PPTX
8 things to know about theming in drupal 8
PDF
Staying Sane with Drupal NEPHP
PPTX
Drupal 7 — Circle theme
The new static resources framework
Anatomy of a reusable module
Drupal 7 Theming - Behind the scenes
Kharkivpy#3: Javascript and Python backend
Built-in query caching for all PHP MySQL extensions/APIs
Drupal Camp Porto - Developing with Drupal: First Steps
Introduction And Basics of Modules in Drupal 7
Extending and Customizing Open Atrium
Backbonejs for beginners
Doctrine 2
Magento 2.0: Prepare yourself for a new way of module development
Introducing Assetic: Asset Management for PHP 5.3
MUC - Moodle Universal Cache
Alfredo-PUMEX
Alfredo-PUMEX
Alfredo-PUMEX
Alfredo-PUMEX
8 things to know about theming in drupal 8
Staying Sane with Drupal NEPHP
Drupal 7 — Circle theme

More from Stefano Valle (7)

PDF
IoT: protocolli, dispositivi, architetture
PDF
Protocol Rollercoaster: da HTTP a AMQP, passando per CoAP e MQTT
PDF
NoSQL Containers get Rich
PDF
Moduli su Zend Framework 2: come sfruttarli
PDF
Introduzione a Git
PDF
Stime e preventivi in un contesto di sviluppo agile
PDF
Introduzione alle metodologie di sviluppo agile
IoT: protocolli, dispositivi, architetture
Protocol Rollercoaster: da HTTP a AMQP, passando per CoAP e MQTT
NoSQL Containers get Rich
Moduli su Zend Framework 2: come sfruttarli
Introduzione a Git
Stime e preventivi in un contesto di sviluppo agile
Introduzione alle metodologie di sviluppo agile

Recently uploaded (20)

PDF
1 - Historical Antecedents, Social Consideration.pdf
PDF
DASA ADMISSION 2024_FirstRound_FirstRank_LastRank.pdf
PDF
Architecture types and enterprise applications.pdf
PDF
ENT215_Completing-a-large-scale-migration-and-modernization-with-AWS.pdf
PPTX
O2C Customer Invoices to Receipt V15A.pptx
PDF
NewMind AI Weekly Chronicles - August'25-Week II
PPTX
OMC Textile Division Presentation 2021.pptx
PDF
A novel scalable deep ensemble learning framework for big data classification...
PDF
Web App vs Mobile App What Should You Build First.pdf
PDF
Getting started with AI Agents and Multi-Agent Systems
PPT
Module 1.ppt Iot fundamentals and Architecture
PPTX
Final SEM Unit 1 for mit wpu at pune .pptx
PDF
2021 HotChips TSMC Packaging Technologies for Chiplets and 3D_0819 publish_pu...
PDF
Microsoft Solutions Partner Drive Digital Transformation with D365.pdf
PDF
WOOl fibre morphology and structure.pdf for textiles
PDF
STKI Israel Market Study 2025 version august
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
Hindi spoken digit analysis for native and non-native speakers
PDF
From MVP to Full-Scale Product A Startup’s Software Journey.pdf
PPTX
Group 1 Presentation -Planning and Decision Making .pptx
1 - Historical Antecedents, Social Consideration.pdf
DASA ADMISSION 2024_FirstRound_FirstRank_LastRank.pdf
Architecture types and enterprise applications.pdf
ENT215_Completing-a-large-scale-migration-and-modernization-with-AWS.pdf
O2C Customer Invoices to Receipt V15A.pptx
NewMind AI Weekly Chronicles - August'25-Week II
OMC Textile Division Presentation 2021.pptx
A novel scalable deep ensemble learning framework for big data classification...
Web App vs Mobile App What Should You Build First.pdf
Getting started with AI Agents and Multi-Agent Systems
Module 1.ppt Iot fundamentals and Architecture
Final SEM Unit 1 for mit wpu at pune .pptx
2021 HotChips TSMC Packaging Technologies for Chiplets and 3D_0819 publish_pu...
Microsoft Solutions Partner Drive Digital Transformation with D365.pdf
WOOl fibre morphology and structure.pdf for textiles
STKI Israel Market Study 2025 version august
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
Hindi spoken digit analysis for native and non-native speakers
From MVP to Full-Scale Product A Startup’s Software Journey.pdf
Group 1 Presentation -Planning and Decision Making .pptx

Asset management with Zend Framework 2

  • 1. ZF2 Asset management with AssetManager module http://www.mvassociati.it/en/gems/php/asset-management-zend-framework-2
  • 2. MODULE’S ASSETS: IMAGES/JS/CSS http://www.flickr.com/photos/tracyleephoto/8322509672
  • 3. Shared between modules Like javascript libraries, logos, buttons, CSS scripts and snippets, etc. 3
  • 4. Shared between modules Like javascript libraries, logos, buttons, CSS scripts and snippets, etc. Where should they be placed? 4
  • 5. Shared between modules Like javascript libraries, logos, buttons, CSS scripts and snippets, etc. Where should they be placed? Inside project /public folder? There is a better way… 5
  • 6. Exclusive of a module Like javascript libraries, images and CSS files that are needed by a single module only 6
  • 7. Exclusive of a module Like javascript libraries, images and CSS files that are needed by a single module only Where should they be placed? 7
  • 8. Exclusive of a module Like javascript libraries, images and CSS files that are needed by a single module only Where should they be placed? Inside that module! 8
  • 9. Possible approaches • Copy & paste of each file inside project /public folder? • Use symlinks? • Tune apache to "look" the files inside each module? 9
  • 10. The way to go: AssetManager 10
  • 11. AssetManager module Resolvers Assets Asset Filters Manager Cache 11
  • 12. AssetManager module Resolvers Assets Asset Manager Resolvers: allowing to define asset naming and locations 12
  • 13. AssetManager module Resolvers Assets Asset Filters Manager Filters: allowing to make some processing before serving assets 13
  • 14. AssetManager module Resolvers Assets Asset Filters Manager Cache: allowing to choose Cache caching policy 14
  • 15. Where to put module assets? all module’s assets 15
  • 16. module.config.php return array( 'asset_manager' => array( 'resolver_configs' => array( 'paths' => array( __DIR__ . '/../assets', ), ),),), ...
  • 17. module.config.php return array( 'asset_manager' => array( 'resolver_configs' => array( 'paths' => array( __DIR__ . '/../assets', ), ),),), ... layout.php echo $this->headLink() ->prependStylesheet($this->basePath() . '/css/aCssFile.css');
  • 18. module.config.php return array( 'asset_manager' => array( 'resolver_configs' => array( 'map' => array( 'css/main.css' => __DIR__.'/../assets/css/main.css', 'css/custom1.css' => __DIR__.'/../assets/css/custom1.css', ), 'collections' => array( 'css/merge.css' => array( 'css/main.css','css/custom1.css', ),),),),), ...
  • 19. module.config.php return array( 'asset_manager' => array( 'resolver_configs' => array( 'map' => array( 'css/main.css' => __DIR__.'/../assets/css/main.css', 'css/custom1.css' => __DIR__.'/../assets/css/custom1.css', ), 'collections' => array( 'css/merge.css' => array( 'css/main.css','css/custom1.css', ),),),),), ... layout.php echo $this->headLink() ->prependStylesheet($this->basePath() . '/css/merge.css');