Skip to content

Commit

Permalink
Change app names to config paths in command arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
bazilio91 committed Dec 12, 2015
1 parent 6d730d6 commit a80f60f
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 11 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@

# ide
.idea
yii2-stubs-generator.iml
yii2-stubs-generator.iml
composer.lock
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
Yii::$app stubs generator for Yii 2
===================================
[![Latest Stable Version](https://poser.pugx.org/bazilio/yii2-stubs-generator/v/stable)](https://packagist.org/packages/bazilio/yii2-stubs-generator)
[![Total Downloads](https://poser.pugx.org/bazilio/yii2-stubs-generator/downloads)](https://packagist.org/packages/bazilio/yii2-stubs-generator)
[![Latest Unstable Version](https://poser.pugx.org/bazilio/yii2-stubs-generator/v/unstable)](https://packagist.org/packages/bazilio/yii2-stubs-generator)
[![License](https://poser.pugx.org/bazilio/yii2-stubs-generator/license)](https://packagist.org/packages/bazilio/yii2-stubs-generator)

This extension provides no-more-butthurt components autocomplete generator command for Yii 2.

Expand Down Expand Up @@ -40,10 +44,10 @@ To use this extension, simply add the following code in your application configu

```
# generate stubs for console application
php yii stubs console
php yii stubs console/config/main.php
# to generate stubs for several apps
php yii stubs console common frontend
php yii stubs console/config/main.php common/config/main.php frontend/config/main.php
```

File with stubs by default located in vendor directory.
Expand All @@ -54,4 +58,4 @@ Usage with PhpStorm
1. Install `File Watchers` JetBrains plugin
2. Open `File Watchers` plugin config and import [watcher.xml](watcher.xml)
3. Edit imported watcher for your needs
4. Add scope for limit trigger to config files: ![](http://monosnap.com/image/I75MVnqdTuyH0LkYnYjIDcTnMege6I.png)
4. Add scope to limit trigger to config files: ![](https://monosnap.com/file/9UdEAsZUxO6XcOxINgm1sucWxuuYu4.png)
11 changes: 5 additions & 6 deletions StubsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,19 +46,18 @@ class ConsoleApplication extends yii\console\Application
TPL;
}

public function actionIndex($app)
public function actionIndex()
{
$path = $this->outputFile ? $this->outputFile : \Yii::$app->getVendorPath() . DIRECTORY_SEPARATOR . 'Yii.php';

$components = [];

foreach (\Yii::$app->requestedParams as $app) {
$configFile = $app . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'main.php';
if (!file_exists($configFile)) {
throw new Exception('Config file doesn\'t exists: ' . $configFile);
foreach (\Yii::$app->requestedParams as $configPath) {
if (!file_exists($configPath)) {
throw new Exception('Config file doesn\'t exists: ' . $configPath);
}

$config = include($configFile);
$config = include($configPath);

foreach ($config['components'] as $name => $component) {
if (!isset($component['class'])) {
Expand Down
2 changes: 1 addition & 1 deletion watcher.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<TaskOptions>
<TaskOptions>
<option name="arguments" value="stubs console common frontend" />
<option name="arguments" value="stubs console/config/main.php common/config/main.php frontend/config/main.php" />
<option name="checkSyntaxErrors" value="true" />
<option name="description" value="" />
<option name="exitCodeBehavior" value="ERROR" />
Expand Down

0 comments on commit a80f60f

Please sign in to comment.