Skip to content
This repository was archived by the owner on Jan 1, 2020. It is now read-only.

Commit f1de7cb

Browse files
committed
Merge branch 'feature/development-mode' into develop
Close #345
2 parents 3fa11ee + 42efb43 commit f1de7cb

File tree

10 files changed

+165
-28
lines changed

10 files changed

+165
-28
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ nbproject
77
.idea
88
.project
99
.settings
10-
vendor
10+
vendor/
1111
composer.phar
12+
config/development.config.php
1213
phpunit.xml

README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,23 @@ interfaces.
2929

3030
**Note:** The built-in CLI server is *for development only*.
3131

32+
## Development mode
33+
34+
The skeleton ships with [zf-development-mode](https://github.com/zfcampus/zf-development-mode)
35+
by default, and provides three aliases for consuming the script it ships with:
36+
37+
```bash
38+
$ composer development-enable # enable development mode
39+
$ composer development-disable # enable development mode
40+
$ composer development-status # whether or not development mode is enabled
41+
```
42+
43+
You may provide development-only modules and bootstrap-level configuration in
44+
`config/development.config.php.dist`, and development-only application
45+
configuration in `config/autoload/development.local.php.dist`. Enabling
46+
development mode will copy these files to versions removing the `.dist` suffix,
47+
while disabling development mode will remove those copies.
48+
3249
## Running Unit Tests
3350

3451
To run the supplied skeleton unit tests, you need to do one of the following:

composer.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
"php": "^5.6 || ^7.0",
1616
"zendframework/zend-component-installer": "^1.0 || ^0.2 || ^1.0.0-dev@dev",
1717
"zendframework/zend-skeleton-installer": "^1.0 || ^0.1.2 || ^1.0.0-dev@dev",
18-
"zendframework/zend-mvc": "^3.0"
18+
"zendframework/zend-mvc": "^3.0",
19+
"zfcampus/zf-development-mode": "^3.0"
1920
},
2021
"autoload": {
2122
"psr-4": {
@@ -102,6 +103,9 @@
102103
]
103104
},
104105
"scripts": {
106+
"development-disable": "zf-development-mode disable",
107+
"development-enable": "zf-development-mode enable",
108+
"development-status": "zf-development-mode status",
105109
"serve": "php -S 0.0.0.0:8080 -t public/ public/index.php"
106110
}
107111
}

composer.lock

Lines changed: 72 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/application.config.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,8 @@
66
* @see http://framework.zend.com/manual/current/en/tutorials/config.advanced.html#environment-specific-application-configuration
77
*/
88
return [
9-
// This should be an array of module namespaces used in the application.
10-
'modules' => [
11-
'Zend\Router',
12-
'Zend\Validator',
13-
'Application',
14-
],
9+
// Retrieve list of modules used in this application.
10+
'modules' => require __DIR__ . '/modules.config.php',
1511

1612
// These are various options for the listeners attached to the ModuleManager
1713
'module_listener_options' => [
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
/**
3+
* Local Configuration Override for DEVELOPMENT MODE.
4+
*
5+
* This configuration override file is for providing configuration to use while
6+
* in development mode. Run:
7+
*
8+
* <code>
9+
* $ composer development-enable
10+
* </code>
11+
*
12+
* from the project root to copy this file to development.local.php and enable
13+
* the settings it contains.
14+
*
15+
* You may also create files matching the glob pattern `{,*.}{global,local}-development.php`.
16+
*/
17+
18+
return [
19+
'view_manager' => [
20+
'display_exceptions' => true,
21+
],
22+
];

config/autoload/local.php.dist

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@
1111
* credentials from accidentally being committed into version control.
1212
*/
1313

14-
return array(
15-
);
14+
return [
15+
];

config/development.config.php.dist

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
/**
3+
* @link http://github.com/zendframework/ZendSkeletonApplication for the canonical source repository
4+
* @copyright Copyright (c) 2005-2016 Zend Technologies USA Inc. (http://www.zend.com)
5+
* @license http://framework.zend.com/license/new-bsd New BSD License
6+
*/
7+
8+
return [
9+
// Additional modules to include when in development mode
10+
'modules' => [
11+
],
12+
// Configuration overrides during development mode
13+
'module_listener_options' => [
14+
'config_glob_paths' => ['config/autoload/{,*.}{global,local}-development.php'],
15+
'config_cache_enabled' => false,
16+
'module_map_cache_enabled' => false,
17+
],
18+
];

config/modules.config.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
/**
3+
* @link http://github.com/zendframework/ZendSkeletonApplication for the canonical source repository
4+
* @copyright Copyright (c) 2005-2016 Zend Technologies USA Inc. (http://www.zend.com)
5+
* @license http://framework.zend.com/license/new-bsd New BSD License
6+
*/
7+
8+
/**
9+
* List of enabled modules for this application.
10+
*
11+
* This should be an array of module namespaces used in the application.
12+
*/
13+
return [
14+
'Zend\Router',
15+
'Zend\Validator',
16+
'Application',
17+
];

public/index.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?php
22

33
use Zend\Mvc\Application;
4+
use Zend\Stdlib\ArrayUtils;
45

56
/**
67
* This makes our life easier when dealing with paths. Everything is relative
@@ -29,5 +30,11 @@
2930
);
3031
}
3132

33+
// Retrieve configuration
34+
$appConfig = require __DIR__ . '/../config/application.config.php';
35+
if (file_exists(__DIR__ . '/../config/development.config.php')) {
36+
$appConfig = ArrayUtils::merge($appConfig, require __DIR__ . '/../config/development.config.php');
37+
}
38+
3239
// Run the application!
33-
Application::init(require __DIR__ . '/../config/application.config.php')->run();
40+
Application::init($appConfig)->run();

0 commit comments

Comments
 (0)