Skip to content
This repository has been archived by the owner on Oct 10, 2019. It is now read-only.

Configuration

neilime edited this page Dec 16, 2016 · 2 revisions

The default configuration is setup to run with "Application ZF2 Skeleton"

1. AssetsBundle

  • boolean production: Define the application environment (development => false). Default true.
  • mixed lastModifiedTime: (optionnal) Allows you to define an arbitrary asset's last modified time in production. Default null : last modified time is calculated for each asset.
  • string basePath : (optionnal) only needed if cacheUrl use @zfBaseUrl. If undefined, \Zend\Http\PhpEnvironment\Request::getBasePath() is used.
  • string cachePath : cache directory absolute path, you can use the @zfRootPath constant corresponding to current working directory. Default @zfRootPath/public/cache.
  • string configCachePath : configuration cache directory absolute path, you can use the @zfRootPath constant corresponding to current working directory. Default @zfRootPath/data/cache.
  • string assetsPath : (optionnal) assets directory absolute path, allows you to define relative path for assets config. You can use the constant @zfRootPath corresponding to current working directory. Default @zfRootPath/public.
  • string cacheUrl : cache directory base url, you can use the constant @zfBaseUrl corresponding to application base url . Default @zfBaseUrl/assets/cache/.
  • array mediaExt : Put here all medias extensions to be cached. Default array('jpg','png','gif','cur','ttf','eot','svg','woff').
  • boolean recursiveSearch: If you define a folder as required asset, it will search for matching assets in that folder and its subfolders. Default false.
  • integer filesPermissions : Permissions for created files. Default 0664
  • integer directoriesPermissions : Permissions for created directories 0775

2. Assets

You can define assets for modules / controllers / action

Exemple :

   <?php
   return array(
           //...
           'assets_bundle' => array(
               //...
   	        'assets' => array(
   			//Common assets included in every pages
   			'css' => array(), //Define css files to include
   			'js' => array(), //Define js files to include
   			'less' => array(), //Define less files to include
   			'media' => array(), //Define images to manage

   			//Modules specific assets
   			'Test' =>  => array( // "Test" is the name of the module

   				'css' => array(),
       			'js' => array(),
       			'less' => array(),
       			'media' => array(),

       			//Controller specific assets
       			'Test\Controller\Name' => array(
       				'css' => array(),
   	    			'js' => array(),
   	    			'less' => array(),
   	    			'media' => array(),

   	    			//Action specific assets
   	    			'ActionName'=> array(
   	    				'css' => array(),
   		    			'js' => array(),
   		    			'less' => array(),
   		    			'media' => array()
       				),
       				//...
       			),
       			//...
       		),
       		//...
   		    )
           ),
           //...
       ),
       //...
   );
  • For each asset, you can specify files or directories. All these elements are related to the asset path by default, but you can specify an absolute path or use the constants "@zfAssetsPath" and "@zfRootPath". If you specify a directory, all files matching the asset type (css, less, js, media) will be included.

  • You can use .php files as assets, there will be interpret.

  • You can use url for js and css assets :

    <?php
        return array(
            //...
            'assets_bundle' => array(
                //...
                'assets' => array(
                    'js' => array('http://ajax.googleapis.com/ajax/libs/mootools/1.4.5/mootools.js'),
                    //...
                )
                //...
            )
            //...
        );

    This example includes Mootools from Google Hosted Libraries

  • You can define an inclusion order like this :

    <?php
        return array(
            //...
            'assets_bundle' => array(
                //...
                'assets' => array(
                    'js' => array('js/firstFile.js','js'),
                    //...
                )
            )
            //...
        );

    This example includes the file "firstFile.js" first, and all other javascript files in the folder "js"

Clone this wiki locally