Skip to content

Use with Zend Skeleton Application

Emilien Escalle edited this page Jan 8, 2019 · 5 revisions

This example shows how to convert Zend Skeleton Application to manage assets via AssetsBundle.


1. Install skeleton application

https://docs.zendframework.com/tutorials/getting-started/skeleton-application/

2. Update dependencies

composer update

3. Install AssetsBundle

Follow the installation instructions

4. Install needed assets filters dependencies

The skeleton application uses css and js files so we have install tedivm/jshrink & tubalmartin/cssmin :

composer require tedivm/jshrink tubalmartin/cssmin

5. Create mandatory directories

mkdir -p data/AssetsBundle/processed public/cache

6. Edit the application module configuration file module/Application/config/module.config.php

Adding the configuration fragment below:

return [
    //...
    'assets_bundle' => [
        'assets' => [
            'css' => [
                'css',
            ],
            'js' => [
                'js/jquery-3.1.0.min.js',
                'js/bootstrap.min.js',
            ],
            'media' => [
                'img',
                'fonts',
            ],
        ]
    ],
    //...
];

7. Edit layout file module/Application/view/layout/layout.phtml, removing prepend function for assets:

// Remove these lines

->prependStylesheet($this->basePath() . '/css/bootstrap-responsive.min.css')
->prependStylesheet($this->basePath() . '/css/style.css')
->prependStylesheet($this->basePath() . '/css/bootstrap.min.css')

 ->prependFile($this->basePath() . '/js/bootstrap.min.js')
 ->prependFile($this->basePath() . '/js/jquery.min.js')

8. Save & Refresh.