zf2-usable-config-project



zf2-usable-config-project

0 0


zf2-usable-config-project

Presentation about ZF2 - Usable and Configurable project

On Github tmquang6805 / zf2-usable-config-project

Zend Framework 2 (ZF2)

Usable and Configurable project

tmquang6805

What?

  • Introduction (this)
  • Installation
  • Public ZF2 modules
  • Private ZF2 modules
  • Configuration in ZF2

What this presentation

Don't

  • I don't talk about what ZF2 is
  • I don't talk about how to develop with ZF2

DO

Installation

if $wifi:

curl -s https://getcomposer.org/installer | php --
php composer.phar create-project -sdev zendframework/skeleton-application .

else:

$pendrive

run it:

Setup your vhost or php 5.4+

php -S 127.0.0.1:8001 -t skeleton-application/public skeleton-application/public/index.php

Public ZF2 Modules

ZF2 module site

ZF2 modules site

Developer tool bar

https://github.com/zendframework/ZendDeveloperTools

How to install

Via Composer (Strongly Recommend)

php composer.phar require zendframework/zend-developer-tools:dev-master

Enable module ZendDeveloperTools

return array(
    // This should be an array of module namespaces used in the application.
    'modules' => array(
        'Application',
        'ZendDeveloperTools',
    ),
    /* other configurations */
);

How to install (cont.)

Copy file

Copy ./vendor/zendframework/zend-developer-tools/config/zenddevelopertools.local.php.dist to ./config/autoload/zenddevelopertools.local.php

Change any settings in it according to your needs.

Private ZF2 Modules

Update composer file

"repositories": [
    {
        "type": "vcs",
        "url": "private-repository"
    }
],
"require": {
    "private-modulename": "dev-master"
}

Run composer update

php composer.phar update

Composer.json

{
    "name": "private-modulename",
    "description": "ZF2 demo",
    "type": "zf-module",
    "homepage": "https://private-repository",
    "authors": [
        {
            "name": "QuangTM",
            "email": "quangtm@hdviet.com"
        }
    ],
    "require": {
        "php": "~5.4",
        "zendframework/zendframework" : "~2.2"
    },
    "autoload": {
        "psr-0": {
            "Backend": "src/"
        },
        "classmap": [
            "./Module.php"
        ]
    }
}

Configuration in ZF2

application.config.php

  • Enable/Disable ZF2 modules

  • Specify autoload config files

  • Cache merged config

module.config.php - config/autoload/{,*.}{global,local}.php

  • Merge configs runtime (if not cached)

  • Right Application Config

application.config.php

Enable/Disable ZF2 modules

'modules' => array(
    'Application',
    'ZendDeveloperTools',
    'Backend',
),

Specify autoload config files

'config_glob_paths' => array(
    'config/autoload/{,*.}{global,local}.php',
),

Cache merged config

  • 'config_cache_enabled' => $booleanValue

  • 'config_cache_key' => $stringKey

  • 'module_map_cache_enabled' => $booleanValue

  • 'module_map_cache_key' => $stringKey

  • 'cache_dir' => $stringPath

Other config files

module.config.php

Effective only for module

{,*.}{global,local}.php

global.config.php

environment and not sensitive to security

local.config.php

environment and sensitive to security