lpinc/lpi-asset-loader

LpiAssetLoader is a zend framework module that can be used in zf2 or zf3 layouts to load front end asset javascript and css files and frameworks

0.1.10 2017-01-22 00:06 UTC

This package is not auto-updated.

Last update: 2024-12-25 09:03:27 UTC


README

Created by LPinc

Introduction

LpiAssetLoader is a zend framework - ZF2 and ZF3 - module that helps configure the loading of front-end custom, bower, or npm javascript and css files and assets.

This module can be especially handy if you load AMD javascript modules in your layouts or view scripts.

Installation

via github

To install LpiAssetLoader, simply recursively clone this repository (git clone --recursive) into your ZF2 or ZF3 modules directory.

Or with composer

  1. Add this project and LpiAssetLoader in your composer.json:

    "require": {
        "lpinc/lpi-asset-loader": "~0.1"
    }
  2. Now tell composer to download ZfcUser by running the command:

    $ php composer.phar update

Enable

Enable LpiAssetLoader in your config/application.config.php file.

Config Options

The LpiAssetLoader module has some options to help customize the basic functionality. After installing LpiAssetLoader, copy ./vendor/lpinc/lpi-asset-loader/config/lpiassetloader.global.php.dist to ./config/autoload/lpiassetloader.global.php and change the values as desired.

If you istalled dojo using nodejs npm, then a sample config might look like this:

$settings = array(
   'dojo_config_settings' => array(
      'async' => true,
      'parseOnLoad' => true
   ),
   'dojo_on' => true,
   'use_source' => true,
   'base_vendor_src_path' => '/node_modules/',
   'amd_vendor_modules' => array(
      'dojo' => 'dojo',
      'dijit' => 'dijit',
      'dojox' => 'dojox'
   )
);

return array(
   'lpi-asset-loader' => $settings
);

Example Uses:

To configue and intialize dojo in a zend framework view-layout file:

if (is_object($this->LpiAssetLoader)) {
   echo $this->LpiAssetLoader->getDojoConfig();
   echo $this->LpiAssetLoader->getDojoInitAssets();
}

To configue dojo with a custom module in a zend framework layout file: