Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
svkurowski committed Sep 9, 2015
0 parents commit 6e2f594
Show file tree
Hide file tree
Showing 6 changed files with 124 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
vendor/
composer.lock
13 changes: 13 additions & 0 deletions Bootstrap.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace svkurowski\shell;

class Bootstrap implements \yii\base\BootstrapInterface
{
public function bootstrap($app)
{
if ($app instanceof \yii\console\Application) {
$app->controllerMap['shell'] = 'svkurowski\shell\ShellController';
}
}
}
6 changes: 6 additions & 0 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Copyright (c) 2015 Sascha Vincent Kurowski <svkurowski@gmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
45 changes: 45 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# An interactive shell for Yii 2

[![Latest Stable Version](https://poser.pugx.org/svkurowski/yii2-shell/version)](https://packagist.org/packages/svkurowski/yii2-shell)
[![Total Downloads](https://poser.pugx.org/svkurowski/yii2-shell/downloads)](https://packagist.org/packages/svkurowski/yii2-shell)
[![License](https://poser.pugx.org/svkurowski/yii2-shell/license)](https://packagist.org/packages/svkurowski/yii2-shell)

This extension for [Yii framework 2.0](http://www.yiiframework.com) applications provides access to an interactive shell for development and debugging.
It wraps the awesome [psysh](http://psysh.org/) application for easy access via the Yii console.

The extension is released under the MIT License.

# Installation

The preferred way to install this extension is through [composer](http://getcomposer.org/download/).

Either run

```
php composer.phar require --dev --prefer-dist svkurowski/yii2-shell
```

or add

```
"svkurowski/yii2-shell": "~1.0.0"
```

to the `require-dev` section of your `composer.json`.


# Usage

After installation, you will be able to run the interactive shell via command line:

```
# Change path to your application's root directory
cd path/to/myapp
# Start the interactive shell
./yii shell
```

You can access the application object using `$this` or `Yii::$app`. Additionally you have access to all your and your dependencies' classes.

See [psysh's website](http://psysh.org/#features) for a list of available features.
28 changes: 28 additions & 0 deletions ShellController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

namespace svkurowski\shell;

use Yii;
use yii\console\Controller;

/**
* Provides access to an interactive shell.
*/
class ShellController extends Controller
{
public $defaultAction = 'run';

/**
* Starts the shell.
*/
public function actionRun()
{
$vars = get_defined_vars();
$vars['this'] = Yii::$app;
$sh = new \Psy\Shell();
$sh->setScopeVariables($vars);
$sh->run();

return self::EXIT_CODE_NORMAL;
}
}
30 changes: 30 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"name": "svkurowski/yii2-shell",
"version": "1.0.0",
"type": "yii2-extension",
"description": "An interactive shell for Yii 2 projects.",
"keywords": ["yii2", "console", "shell", "repl"],
"license": "MIT",
"support": {
"issues": "https://github.com/svkurowski/yii2-shell/issues",
"source": "https://github.com/svkurowski/yii2-shell"
},
"authors": [
{
"name": "Sascha Vincent Kurowski",
"email": "svkurowski@gmail.com"
}
],
"require": {
"yiisoft/yii2": "*",
"psy/psysh": "0.5.*"
},
"autoload": {
"psr-4": {
"svkurowski\\shell\\": ""
}
},
"extra": {
"bootstrap": "svkurowski\\shell\\Bootstrap"
}
}

0 comments on commit 6e2f594

Please sign in to comment.