PHPackages                             loadsys/cakephp-config-read - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [CLI &amp; Console](/categories/cli)
4. /
5. loadsys/cakephp-config-read

ActiveCakephp-plugin[CLI &amp; Console](/categories/cli)

loadsys/cakephp-config-read
===========================

A CakePHP plugin that provides a Shell to read an app's Configure vars from the command line.

4.0.0(7y ago)316.8k[2 issues](https://github.com/loadsys/CakePHP-ConfigReadShell/issues)[1 PRs](https://github.com/loadsys/CakePHP-ConfigReadShell/pulls)MITPHPPHP &gt;=7.0

Since Jan 6Pushed 7y ago10 watchersCompare

[ Source](https://github.com/loadsys/CakePHP-ConfigReadShell)[ Packagist](https://packagist.org/packages/loadsys/cakephp-config-read)[ Docs](https://github.com/loadsys/CakePHP-ConfigReadShell)[ RSS](/packages/loadsys-cakephp-config-read/feed)WikiDiscussions master Synced 1w ago

READMEChangelog (6)Dependencies (5)Versions (21)Used By (0)

CakePHP-ConfigReadShell
=======================

[](#cakephp-configreadshell)

[![Latest Version](https://camo.githubusercontent.com/5bc47d0c1a814f48b6d6573f4bb71db8a9bdcf732364636571eaa7d9a00c69ad/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f6c6f61647379732f43616b655048502d436f6e666967526561645368656c6c2e7376673f7374796c653d666c61742d737175617265)](https://github.com/loadsys/CakePHP-ConfigReadShell/releases)[![Build Status](https://camo.githubusercontent.com/c1e349035f58fb8bed1c3896a91dcf40a01d6c37c8eb742c4bd986e7d5f96da0/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f6c6f61647379732f43616b655048502d436f6e666967526561645368656c6c2f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/loadsys/CakePHP-ConfigReadShell)[![Coverage Status](https://camo.githubusercontent.com/05045de9e347a5448a50a1803b746b5017165134961e727fdf5c440e30adc968/68747470733a2f2f696d672e736869656c64732e696f2f636f766572616c6c732f6c6f61647379732f43616b655048502d436f6e666967526561645368656c6c2f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://coveralls.io/r/loadsys/CakePHP-ConfigReadShell)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Total Downloads](https://camo.githubusercontent.com/c1b70445c3f8241c36f4000673b8b57bf92b02e8e0f8494437c40fff6038b18a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6c6f61647379732f63616b657068702d636f6e6669672d726561642e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/loadsys/cakephp-config-read)

A CakePHP plugin that provides a Shell to read an app's Configure vars from the command line.

Installation
------------

[](#installation)

Use the following as a guide for choosing your version based on the version of CakePHP installed.

CakePHPConfigReadShell PluginTagNotes^3.4[master](https://github.com/loadsys/CakePHP-ConfigReadShell/tree/master)4.0.0stable3.3[3.3](https://github.com/loadsys/CakePHP-ConfigReadShell/tree/3.0.0)3.0.0stable2.5[2.x](https://github.com/loadsys/CakePHP-ConfigReadShell/tree/2.0.1)2.0.1stable1.3[1.x](https://github.com/loadsys/CakePHP-ConfigReadShell/tree/1.0.1)1.0.1stable### This will install the latest version.

[](#this-will-install-the-latest-version)

```
$ composer require loadsys/cakephp-config-read:~4.0
```

**Note:** we don't expect to actively maintain or improve the 1.3 version. It's here because the project started life as a 1.3 Shell.

Requirements
------------

[](#requirements)

- PHP 7.0+
- CakePHP 3.6.0+

Usage
-----

[](#usage)

Imagine the following defined in `config/app.php`:

```
return [
	'Key' => [
		'Name' => 'foo',
	],
	'Second' => [
		'Key' => [
			'First' => 'bar',
			'Second' => 'baz',
			'Third' => 42,
		],
	],
];
```

To use this plugin, call it from the command line:

```
$ cd path/to/app/
$ ./bin/cake config_read Key.Name
'foo'
```

### Format as a bash variable definition

[](#format-as-a-bash-variable-definition)

```
$ ./bin/cake ConfigRead.ConfigRead Key.Name Second.Key
KEY_NAME='foo'
SECOND_KEY_FIRST='bar'
SECOND_KEY_SECOND='baz'
SECOND_KEY_THIRD='42'
```

Note that this format is automatically used whenever more than one key is returned (unless the `--serialize` switch has been used). For example, if you request a key that contains an array, all values in the array will be returned sequentially. Alternatively, if you pass multiple keys on the command line, they will all be returned. The format can also be forced using the `-b` or `--bash` command line switch:

```
$ ./bin/cake config_read -b Key.Name
KEY_NAME='foo'
```

### Serializing output

[](#serializing-output)

It is possible serialize the output from ConfigReadShell so that it can be consumed by other PHP scripts more easily by using the `-s` or `--serialize` command line switch.

Requesting multiple keys on the command line will produce an array of those keys. Requesting a single scalar value will produce only that scalar value.

This switch always overrides both the `--bash` switch and the Shell's automatic bash formatting.

```
$ ./bin/cake config_read -s Key.Name Second.Key
a:2:{s:8:"Key.Name";s:3:"foo";s:10:"Second.Key";a:3:{s:5:"First";s:3:"bar";s:6:"Second";s:3:"baz";s:5:"Third";i:42;}}
# Check the result by piping into PHP and unserializing the result.
$ ./bin/cake ConfigRead.ConfigRead -s Key.Name Second.Key | php -r 'print_r(unserialize(file_get_contents("php://stdin")));'
Array
(
    [Key.Name] => foo

    [Second.Key] => Array
		(
			[First] => bar
			[Second] => baz
			[Third] => 42
		)

)
```

Potential Gotchas
-----------------

[](#potential-gotchas)

### "Consumed" Configure Vars

[](#consumed-configure-vars)

CakePHP 3 by default "consumes" some of its configs so as not to confuse developers. [`Configure::consume()`](http://book.cakephp.org/3.0/en/development/configuration.html#Cake%5CCore%5CConfigure::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:

*`[Configure.Key]`**`Class::configEnumerationMethod()`**`Class::configFetchMethod()`*`[Cache]``Cache::configured()``Cache::getConfig()``[Datasources]``ConnectionManager::configured()``ConnectionManager::getConfig()``[EmailTransport]``Email::configuredTransport()``Email::getConfigTransport()``[Email]``Email::configured()``Email::getConfig()``[Log]``Log::configured()``Log::getConfig()``[Security.salt]`*(none)*`Security::getSalt()`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` -&gt; `localhost`) while in the background it is actually querying `ConnectionManager::getConfig('default')['host']`. (This is particularly helpful if you are using [Environment-Aware Configs](https://github.com/beporter/CakePHP-EnvAwareness/tree/master/slides).)

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 `::getConfig()` and `::configured()` available.

⚠️ **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.**

Contributing
------------

[](#contributing)

### Code of Conduct

[](#code-of-conduct)

This project has adopted the Contributor Covenant as its [code of conduct](CODE_OF_CONDUCT.md). All contributors are expected to adhere to this code. [Translations are available](http://contributor-covenant.org/).

### Reporting Issues

[](#reporting-issues)

Please use [GitHub Isuses](https://github.com/loadsys/CakePHP-ConfigReadShell/issues) for listing any known defects or issues.

### Development

[](#development)

When developing this plugin, please fork and issue a PR for any new development.

License
-------

[](#license)

[MIT](https://github.com/loadsys/CakePHP-ConfigReadShell/blob/master/LICENSE.md)

Copyright
---------

[](#copyright)

[Loadsys Web Strategies](http://www.loadsys.com) 2018

###  Health Score

31

—

LowBetter than 66% of packages

Maintenance7

Infrequent updates — may be unmaintained

Popularity23

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity67

Established project with proven stability

 Bus Factor1

Top contributor holds 68.8% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~92 days

Recently: every ~301 days

Total

16

Last Release

2787d ago

Major Versions

1.0.0 → 2.0.02015-01-06

1.0.1 → 2.0.12015-02-25

2.0.1 → 3.0.02015-04-02

2.1.1 → 3.1.12015-06-15

3.3.1 → 4.0.02018-10-22

PHP version history (3 changes)3.0.2PHP &gt;=5.4.19

3.1.2PHP &gt;=5.4

4.0.0PHP &gt;=7.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/58c6913a72757502a801ebc71f995eb1c4f7a53a7de7314a20b9a1f1d6131b60?d=identicon)[jtyost2](/maintainers/jtyost2)

![](https://www.gravatar.com/avatar/2380c6ad9546e6c8ce5c5b641f5a4bce0c4d3e7f3a377dc287936dff50cc3064?d=identicon)[ricog](/maintainers/ricog)

---

Top Contributors

[![beporter](https://avatars.githubusercontent.com/u/637270?v=4)](https://github.com/beporter "beporter (53 commits)")[![justinyost](https://avatars.githubusercontent.com/u/85320?v=4)](https://github.com/justinyost "justinyost (19 commits)")[![kriskd](https://avatars.githubusercontent.com/u/193937?v=4)](https://github.com/kriskd "kriskd (5 commits)")

---

Tags

shellcakephpconfigure

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/loadsys-cakephp-config-read/health.svg)

```
[![Health](https://phpackages.com/badges/loadsys-cakephp-config-read/health.svg)](https://phpackages.com/packages/loadsys-cakephp-config-read)
```

###  Alternatives

[dereuromark/cakephp-ide-helper

CakePHP IdeHelper Plugin to improve auto-completion

1902.3M39](/packages/dereuromark-cakephp-ide-helper)[cakephp/bake

Bake plugin for CakePHP

11211.7M189](/packages/cakephp-bake)[helsingborg-stad/municipio

A bootstrap theme for creating municipality sites.

4028.3k10](/packages/helsingborg-stad-municipio)[dereuromark/cakephp-tools

A CakePHP plugin containing lots of useful and reusable tools

336972.2k49](/packages/dereuromark-cakephp-tools)[dereuromark/cakephp-queue

The Queue plugin for CakePHP provides deferred task execution.

309914.0k25](/packages/dereuromark-cakephp-queue)[kamisama/cake-resque

A CakePHP plugin for creating background jobs with Resque

159417.3k](/packages/kamisama-cake-resque)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
