Skip to content

Commit 41e67ab

Browse files
Jurigagsergeyklay
authored andcommitted
Added parameters loading from additional devtools config file
1 parent c01096a commit 41e67ab

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,26 @@ $config = [
147147
];
148148
```
149149

150+
## Configuration file
151+
152+
By creating **phalcon.json** or any other configuration file called **phalcon** in root project you can set options for all possible commands, for example:
153+
154+
```json
155+
{
156+
"migration" : {
157+
"migrations": "App/Migrations",
158+
"config": "App/Config/db.ini"
159+
},
160+
"controller" : {
161+
"namespace": "Phalcon\\Test",
162+
"directory": "App/Controllers",
163+
"base-class": "App\\MyAbstractController"
164+
}
165+
}
166+
```
167+
168+
And then you can use use `phalcon migration run` or `phalcon controller SomeClass` and those commands will be executed with options from file. Arguments provided by developer from command line will overwrite existing one in file.
169+
150170
## License
151171

152172
Phalcon Developer Tools is open source software licensed under the [New BSD License][:license:].<br>

scripts/Phalcon/Commands/Command.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,18 @@ public function parseParameters(array $parameters = [], $possibleAlias = [])
301301
}
302302
}
303303

304+
foreach (['ini', 'php', 'json', 'yaml'] as $extension) {
305+
if (file_exists("phalcon.".$extension)) {
306+
$config = $this->loadConfig("phalcon.".$extension);
307+
$commandName = $this->getCommands()[0];
308+
$optionsToMerge = $config->get($commandName);
309+
if (!empty($optionsToMerge)) {
310+
$receivedParams = array_merge($optionsToMerge->toArray(), $receivedParams);
311+
}
312+
break;
313+
}
314+
}
315+
304316
$this->_parameters = $receivedParams;
305317

306318
return $receivedParams;

0 commit comments

Comments
 (0)