Skip to content

Commit c593e58

Browse files
committed
Merge pull request #26 from loadsys/f/readme-cleanup
F/readme cleanup
2 parents 5c6ab1a + 0ebd300 commit c593e58

3 files changed

Lines changed: 20 additions & 17 deletions

File tree

README.md

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# CakePHP-ConfigReadShell
22

33
[![Latest Version](https://img.shields.io/github/release/loadsys/CakePHP-ConfigReadShell.svg?style=flat-square)](https://github.com/loadsys/CakePHP-ConfigReadShell/releases)
4-
[![Build Status](https://travis-ci.org/loadsys/CakePHP-ConfigReadShell.svg?branch=master)](https://travis-ci.org/loadsys/CakePHP-ConfigReadShell)
5-
[![Coverage Status](https://coveralls.io/repos/loadsys/CakePHP-ConfigReadShell/badge.svg?branch=master)](https://coveralls.io/r/loadsys/CakePHP-ConfigReadShell?branch=master)
4+
[![Build Status](https://img.shields.io/travis/loadsys/CakePHP-ConfigReadShell/master.svg?style=flat-square)](https://travis-ci.org/loadsys/CakePHP-ConfigReadShell)
5+
[![Coverage Status](https://img.shields.io/coveralls/loadsys/CakePHP-ConfigReadShell/master.svg?style=flat-square)](https://coveralls.io/r/loadsys/CakePHP-ConfigReadShell)
66
[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE.md)
77
[![Total Downloads](https://img.shields.io/packagist/dt/loadsys/cakephp-config-read.svg?style=flat-square)](https://packagist.org/packages/loadsys/cakephp-config-read)
88

@@ -105,18 +105,21 @@ Array
105105

106106
CakePHP 3 by default "consumes" some of its configs so as not to confused developers. [`Configure::consume()`](http://book.cakephp.org/3.0/en/development/configuration.html#Cake\Core\Configure::consume) removes the configuration key from Configure, making it unavailable to the rest of the app. At the [time of this writing](https://github.com/cakephp/app/blob/a0f2c4/config/bootstrap.php#L136,L141), it does this for the following keys/classes:
107107

108-
* Cache/Cache
109-
* Datasources/ConnectionManager
110-
* EmailTransport/Email
111-
* Email/Email
112-
* Log/Log
113-
* Security.salt/Security::salt()
108+
| _`[Configure.Key]`_ | _`Class::configEnumerationMethod()`_ | _`Class::configFetchMethod()`_ |
109+
|----------------------|---------------------------------------|---------------------------------|
110+
| `[Cache]` | `Cache::configured()` | `Cache::config()` |
111+
| `[Datasources]` | `ConnectionManager::configured()` | `ConnectionManager::config()` |
112+
| `[EmailTransport]` | `Email::configuredTransport()` | `Email::configTransport()` |
113+
| `[Email]` | `Email::configured()` | `Email::config()` |
114+
| `[Log]` | `Log::configured()` | `Log::config()` |
115+
| `[Security.salt]` | _(none)_ | `Security::salt()` |
114116

115-
The ConfigReadShell devotes about half of its codebase dealing with this for you, allowing you to continue to fetch values using the Configure path (`Datasources.default.host` -> `localhost`) while in the background querying `ConnectionManager::config('default')['host']`. (This is particularly helpful if you are using [Environment-Aware Configs](https://github.com/beporter/CakePHP-EnvAwareness/tree/master/slides).)
116117

117-
The "gotcha" here is that ConfigReadShell has to maintain a static list of Configure keys that are consumed, and how to access them in their new container. **If your app consumes a non-standard Configure key during bootstrapping, you will not be able to obtain it from the ConfigReadShell.**
118+
The ConfigReadShell devotes about half of its codebase dealing with this for you, allowing you to continue to fetch values using the Configure path (`Datasources.default.host` -> `localhost`) while in the background it is actually querying `ConnectionManager::config('default')['host']`. (This is particularly helpful if you are using [Environment-Aware Configs](https://github.com/beporter/CakePHP-EnvAwareness/tree/master/slides).)
118119

119-
An additionally exception is `EmailTransport`, which doesn't have a way of enumerating the named configs it is storing. Basically: `EmailTransport.default` will work, but just `EmailTransport` will not. (This caveat will no longer be an issue if cakephp/cakephp#6969 is merged.)
120+
The "gotcha" here is that ConfigReadShell has to maintain a hard-coded list of Configure keys that are normally consumed, and how to access them in their new container. This is further complicated by the fact that not all consumed configs are loaded into or retrieved from their containers the same way, although the base assumption is that the container implements the [`StaticConfigTrait`](http://api.cakephp.org/3.0/class-Cake.Core.StaticConfigTrait.html) and so will have `::config()` and `::configured()` available.
121+
122+
:warning: **If your app uses `Configure::consume()` on any non-standard Configure key during bootstrapping, you will not be able to obtain any child values of those keys from the ConfigReadShell.**
120123

121124

122125
## Contributing

composer.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,12 @@
2222
"require": {
2323
"php": ">=5.4",
2424
"cakephp/cakephp": "~3.0",
25-
"composer/installers": "~1.0"
25+
"composer/installers": "~1.0",
26+
"psy/psysh": "@stable"
2627
},
2728
"require-dev": {
2829
"phpunit/phpunit": "~4.1",
29-
"loadsys/loadsys_codesniffer": "~3.0",
30+
"loadsys/loadsys_codesniffer": "dev-master",
3031
"satooshi/php-coveralls": "dev-master"
3132
},
3233
"autoload": {

tests/TestCase/Shell/ConfigReadShellTest.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ public function testStartupFlags($params, $args, $expected) {
276276
$this->Shell->args = $args;
277277

278278
$this->Shell->startup();
279-
279+
280280
foreach ($expected as $prop => $check) {
281281
$this->assertEquals(
282282
$check['val'],
@@ -302,7 +302,7 @@ public function provideStartupArgs() {
302302
],
303303
],
304304
],
305-
305+
306306
[
307307
[],
308308
['dummy', 'dummy2'],
@@ -317,7 +317,7 @@ public function provideStartupArgs() {
317317
],
318318
],
319319
],
320-
320+
321321
[
322322
['serialize' => true],
323323
['dummy', 'dummy2'],
@@ -332,7 +332,6 @@ public function provideStartupArgs() {
332332
],
333333
],
334334
],
335-
336335
];
337336
}
338337

0 commit comments

Comments
 (0)