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

Conversation

@weierophinney
Copy link
Member

@weierophinney weierophinney commented Jun 21, 2016

zf-development-mode has been a popular feature of Apigility, and a popular standalone module. This patch adds v3 of that package, which has been re-engineered to work as a standalone script (vs as a console-based MVC controller). In particular:

  • I've added config/development.config.php.dist, to allow specifying bootstrap-level configuration to use when development mode is enabled (including additional modules, changes in configuration caching, etc.)
  • I've added config/autoload/development.local.php.dist, to allow specifying application-level configuration to use when development mode is enabled; by default, this includes enabling error display in zend-mvc views.
  • I've split module listing out to config/modules.config.php, as we did in the Apigility skeleton. This provides a single file in which to view them, and simplifies auto-generation of that list.
  • I've added three composer scripts to simplify working with development mode:
    • composer development-enable
    • composer development-disable
    • composer development-status

Notes

This PR originally took the route of creating a script within the skeleton, bin/development-mode. That approach was scrapped in favor of producing an updated version of zfcampus/zf-development-mode that had no external dependencies.

@weierophinney weierophinney added this to the 3.0.0 milestone Jun 21, 2016
{
if (! file_exists('config/development.config.php')) {
// nothing to do
echo "Development mode was already disabled.", PHP_EOL;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why " not just ' ?

@weierophinney
Copy link
Member Author

Ping @akrabat - thoughts? The other direction I could take is to do a v3 release of zend-development-mode that just ships this script, instead of acting as a module, and require that in the ZF skeleton.

// Retrieve configuration
$appConfig = require __DIR__ . '/../config/application.config.php';
if (file_exists(__DIR__ . '/config/development.config.php')) {
$appConfig = ArrayUtils::merge($appConfig, require __DIR__ . '/../config/development.config.php');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

file_exists and require are checking for different files

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, @alextech - fixing now!

@michalbundyra
Copy link
Member

The code in development-mode is quite long.... Wouldn't be nicer to write a class and create new instance with $argv?

class DevelopmentMode {
    public function __construct(array $argv)
    {
        ...
    }
}

new DevelopmentMode($argv);

I don't like this procedural style...

@weierophinney
Copy link
Member Author

I don't like this procedural style...

Matter of preference. I don't care either way; this was relatively easy, and didn't require mixing a class and a script in a single file, or pushing a class into the skeleton source tree. If we were to do move this into zend-development-mode, I'd likely switch to a class, however.


$config = getApplicationConfig();
if (isset($config['module_listener_options']['cache_dir'])
&& ! empty($config['module_listener_options']['cache_dir'])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

!empty is enough

@weierophinney
Copy link
Member Author

Alternate version available in zfcampus/zf-development-mode#19 (pinging @webimpress and @akrabat)

@weierophinney
Copy link
Member Author

I've updated this pull request to use zf-development-mode v3, and added several composer script aliases to simplify working with it.

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
```
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.
@weierophinney weierophinney merged commit 42efb43 into zendframework:develop Jun 22, 2016
weierophinney added a commit that referenced this pull request Jun 22, 2016
@weierophinney weierophinney deleted the feature/development-mode branch June 22, 2016 22:32

```bash
$ composer development-enable # enable development mode
$ composer development-disable # enable development mode
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/enable/disable

@akrabat
Copy link
Contributor

akrabat commented Jun 26, 2016

Was afk all week. +1 from me, though note typo in README.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants