From 01228ddd09aed76fa3483ff70f03618824d32d75 Mon Sep 17 00:00:00 2001 From: Matthew Weier O'Phinney Date: Tue, 21 Jun 2016 17:11:38 -0500 Subject: [PATCH 1/4] Provide development mode zend-development-mode has been a popular feature of Apigility, and a popular standalone module. Unfortunately, its architecture uses the MVC <-> console integration, which is problematic in the streamlined skeleton, which does not include that out-of-the-box. This patch creates development-mode as as standalone script in the project `bin/` directory. Additionally, we add the `config/modules.config.php`, to push modules into a separate file, and `config/development.config.php.dist`, to provide a basic structure for segregated configuration. Finally, the bootstrap is updated to test for the presence of `config/development.config.php` and merge its contents with the application configuration. Usage is: ```bash $ ./bin/development-mode enable ``` Or, to disable: ```bash $ ./bin/development-mode disable ``` --- bin/development-mode | 235 +++++++++++++++++++++++++++++ config/application.config.php | 8 +- config/development.config.php.dist | 18 +++ config/modules.config.php | 17 +++ public/index.php | 9 +- 5 files changed, 280 insertions(+), 7 deletions(-) create mode 100755 bin/development-mode create mode 100644 config/development.config.php.dist create mode 100644 config/modules.config.php diff --git a/bin/development-mode b/bin/development-mode new file mode 100755 index 0000000000..b728be8265 --- /dev/null +++ b/bin/development-mode @@ -0,0 +1,235 @@ +#!/usr/bin/env php + [ - 'Zend\Router', - 'Zend\Validator', - 'Application', - ], + // Retrieve list of modules used in this application. + 'modules' => require __DIR__ . '/modules.config.php', // These are various options for the listeners attached to the ModuleManager 'module_listener_options' => [ diff --git a/config/development.config.php.dist b/config/development.config.php.dist new file mode 100644 index 0000000000..2446217177 --- /dev/null +++ b/config/development.config.php.dist @@ -0,0 +1,18 @@ + [ + ], + // development time configuration globbing + 'module_listener_options' => [ + 'config_glob_paths' => ['config/autoload/{,*.}{global,local}-development.php'], + 'config_cache_enabled' => false, + 'module_map_cache_enabled' => false, + ], +]; diff --git a/config/modules.config.php b/config/modules.config.php new file mode 100644 index 0000000000..92ac3cfd4e --- /dev/null +++ b/config/modules.config.php @@ -0,0 +1,17 @@ +run(); +Application::init($appConfig)->run(); From 1416d389fc65a88fe2652c2387563d31b3110c5c Mon Sep 17 00:00:00 2001 From: Matthew Weier O'Phinney Date: Tue, 21 Jun 2016 17:42:26 -0500 Subject: [PATCH 2/4] Normalize all quotation marks. --- bin/development-mode | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/bin/development-mode b/bin/development-mode index b728be8265..cb10255823 100755 --- a/bin/development-mode +++ b/bin/development-mode @@ -73,7 +73,7 @@ function disable() { if (! file_exists('config/development.config.php')) { // nothing to do - echo "Development mode was already disabled.", PHP_EOL; + echo 'Development mode was already disabled.', PHP_EOL; return 0; } @@ -86,7 +86,7 @@ function disable() removeConfigCacheFile(getConfigCacheFile()); - echo "Development mode is now disabled.", PHP_EOL; + echo 'Development mode is now disabled.', PHP_EOL; return 0; } @@ -99,14 +99,14 @@ function enable() { if (file_exists('config/development.config.php')) { // nothing to do - echo "Already in development mode!", PHP_EOL; + echo 'Already in development mode!', PHP_EOL; return 0; } if (! file_exists('config/development.config.php.dist')) { fwrite( STDERR, - "MISSING \"config/development.config.php.dist\". Could not switch to development mode!" . PHP_EOL + 'MISSING "config/development.config.php.dist". Could not switch to development mode!' . PHP_EOL ); return 1; } From 6995de4ff2cf7961ebd5f29b67d69cc829ec126b Mon Sep 17 00:00:00 2001 From: Matthew Weier O'Phinney Date: Tue, 21 Jun 2016 17:43:34 -0500 Subject: [PATCH 3/4] Fix path in bootstrap script --- public/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/index.php b/public/index.php index 3dd188e282..4343eb7559 100644 --- a/public/index.php +++ b/public/index.php @@ -32,7 +32,7 @@ // Retrieve configuration $appConfig = require __DIR__ . '/../config/application.config.php'; -if (file_exists(__DIR__ . '/config/development.config.php')) { +if (file_exists(__DIR__ . '/../config/development.config.php')) { $appConfig = ArrayUtils::merge($appConfig, require __DIR__ . '/../config/development.config.php'); } From 42efb43e1a7f5f0938a95f6f0c3f81c9948b44b9 Mon Sep 17 00:00:00 2001 From: Matthew Weier O'Phinney Date: Wed, 22 Jun 2016 15:59:19 -0500 Subject: [PATCH 4/4] Use zf-development-mode instead This patch removes `bin/development-mode` in favor of requiring zfcampus/zf-development-mode v3. The various commands in zf-development-mode have been aliased as composer scripts, and documented in the README file. It also adds `config/autoload/development.local.php.dist`, and ensures all configuration files are properly documented and use short array notation. --- .gitignore | 3 +- README.md | 17 ++ bin/development-mode | 235 --------------------- composer.json | 6 +- composer.lock | 89 ++++++-- config/autoload/development.local.php.dist | 22 ++ config/autoload/local.php.dist | 4 +- config/development.config.php.dist | 4 +- 8 files changed, 122 insertions(+), 258 deletions(-) delete mode 100755 bin/development-mode create mode 100644 config/autoload/development.local.php.dist diff --git a/.gitignore b/.gitignore index a0a70c8e73..a9a82082b2 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,7 @@ nbproject .idea .project .settings -vendor +vendor/ composer.phar +config/development.config.php phpunit.xml diff --git a/README.md b/README.md index 4afa7cd236..8de482fcb0 100644 --- a/README.md +++ b/README.md @@ -29,6 +29,23 @@ interfaces. **Note:** The built-in CLI server is *for development only*. +## Development mode + +The skeleton ships with [zf-development-mode](https://github.com/zfcampus/zf-development-mode) +by default, and provides three aliases for consuming the script it ships with: + +```bash +$ composer development-enable # enable development mode +$ composer development-disable # enable development mode +$ composer development-status # whether or not development mode is enabled +``` + +You may provide development-only modules and bootstrap-level configuration in +`config/development.config.php.dist`, and development-only application +configuration in `config/autoload/development.local.php.dist`. Enabling +development mode will copy these files to versions removing the `.dist` suffix, +while disabling development mode will remove those copies. + ## Running Unit Tests To run the supplied skeleton unit tests, you need to do one of the following: diff --git a/bin/development-mode b/bin/development-mode deleted file mode 100755 index cb10255823..0000000000 --- a/bin/development-mode +++ /dev/null @@ -1,235 +0,0 @@ -#!/usr/bin/env php - + * $ composer development-enable + * + * + * from the project root to copy this file to development.local.php and enable + * the settings it contains. + * + * You may also create files matching the glob pattern `{,*.}{global,local}-development.php`. + */ + +return [ + 'view_manager' => [ + 'display_exceptions' => true, + ], +]; diff --git a/config/autoload/local.php.dist b/config/autoload/local.php.dist index 78145f3012..dd3fa6e83e 100644 --- a/config/autoload/local.php.dist +++ b/config/autoload/local.php.dist @@ -11,5 +11,5 @@ * credentials from accidentally being committed into version control. */ -return array( -); +return [ +]; diff --git a/config/development.config.php.dist b/config/development.config.php.dist index 2446217177..9d56187c17 100644 --- a/config/development.config.php.dist +++ b/config/development.config.php.dist @@ -6,10 +6,10 @@ */ return [ - // Development time modules + // Additional modules to include when in development mode 'modules' => [ ], - // development time configuration globbing + // Configuration overrides during development mode 'module_listener_options' => [ 'config_glob_paths' => ['config/autoload/{,*.}{global,local}-development.php'], 'config_cache_enabled' => false,