loadsys / cakephp-configreadshell Goto Github PK
View Code? Open in Web Editor NEWA CakePHP plugin that provides a Shell to read an app's Configure vars from the command line.
License: MIT License
A CakePHP plugin that provides a Shell to read an app's Configure vars from the command line.
License: MIT License
Cake 3 by default strips a lot of Configure's values out via ::consume()
. This is done in config/boostrap.php
for:
Using Configure::consume()
is meant to keep the values left in Configure
specific to the given app (I guess), but it greatly complicates the process of obtaining environment-specific Configure values for "anything" in the app since those configs need to be fetch by calling the appropriate singleton class instead (example: ConnectionManager::config('default)
).
The ConfigReadShell's documentation needs to spell out that if you're trying to get a "consumed" value, it won't work unless you edit your bootstrap.php to use Configure::read()
instead of Configure::consume()
.
Another option is to invoke the Cake ConsoleShell:
$ echo 'use Cake\Datasource\ConnectionManager; ConnectionManager::config("default");'
| bin/cake Console
Welcome to CakePHP v3.0.7 Console
---------------------------------------------------------------
App : src
Path: /var/www/src/
---------------------------------------------------------------
You can exit with `CTRL-C` or `exit`
Psy Shell v0.4.4 (PHP 5.6.10-1+deb.sury.org~precise+1 โ cli) by Justin Hileman
=> [
"className" => "Cake\\Database\\Connection",
"driver" => "Cake\\Database\\Driver\\Mysql",
"persistent" => false,
"host" => "localhost",
"username" => "vagrant",
"password" => "vagrant",
"database" => "vagrant",
"encoding" => "utf8",
"timezone" => "UTC",
"cacheMetadata" => true,
"quoteIdentifiers" => false,
"name" => "default"
]
Exit: Ctrl+D
Obviously there's another problem with this, since the ConsoleShell spits out a bunch of other extraneous garbage. This could be mitigated with a --quiet
option to suppress that stuff, but that would involve customizing your ConsoleShell
instead of your bootstrap.
Update to: "composer/installers": "~1.0",
Seems like this might be the cause of composer install
creating a /Plugin
root folder and installing every package that has a type: cakephp-plugin
in their own composer.json
into that (tracked) folder.
It's not clear to me how to detect whether this plugin is being composer install
ed via composer v1 or v2, but on the master / 4.x
branch it's probably safe to remove composer/installers
from the composer.json
file in THIS project.
The issue is fixed when a different project that runs composer require loadsys/cakephp-config-read:~4.0
should NOT end up with a root Plugin/
folder when running composer install
.
It would be handy to be able to spit out a sub-section of a Cake app's Configure array in a format that could be consumed by another PHP script easily. This would improve the fidelity of data transfer for things like our Shell Scripts' db-credentials
script, which currently uses the ConfigReadShell to dump DB connection values to bash variables, then has to parse that format back into a PHP data structure before spitting it back out in the appropriate format itself.
It'd be great to be able to do something like this from a calling script instead:
<?php
$cmd = escapeshellcmd('bin/cake ConfigRead --serialize Key.SubValueWithSubArrays');
$serialized = [];
$code = 0;
exec($cmd, $serialized, $code);
$data = unserialize($serialized);
echo $data['sub-sub-key']['property'];
$ composer update
Loading composer repositories with package information
Updating dependencies (including require-dev)
- Removing loadsys/cakephp-config-read (2.1.1)
- Installing loadsys/cakephp-config-read (3.1.1)
Loading from cache
[RuntimeException]
Unable to get primary namespace for package loadsys/cakephp-config-read.
Ensure you have added proper 'autoload' section to your plugin's config as
stated in README on https://github.com/cakephp/plugin-installer
To follow convention, this package should probably be named loadsys/cakephp-configread
or cakephp-config-read
.
cake-2.x
branch, turn master into Cake 3.x compatible.3.0.0
.A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.