Repository: yiisoft/yii2-shell Branch: master Commit: 747678498438 Files: 15 Total size: 11.2 KB Directory structure: gitextract_r687wq14/ ├── .editorconfig ├── .gitattributes ├── .github/ │ ├── CONTRIBUTING.md │ ├── FUNDING.yml │ ├── ISSUE_TEMPLATE.md │ ├── PULL_REQUEST_TEMPLATE.md │ └── SECURITY.md ├── .gitignore ├── Bootstrap.php ├── CHANGELOG.md ├── LICENSE.md ├── README.md ├── ShellController.php ├── YiiCaster.php └── composer.json ================================================ FILE CONTENTS ================================================ ================================================ FILE: .editorconfig ================================================ # editorconfig.org root = true [*] charset = utf-8 end_of_line = lf insert_final_newline = true indent_style = space indent_size = 4 trim_trailing_whitespace = true [*.md] trim_trailing_whitespace = false ================================================ FILE: .gitattributes ================================================ # Ignore all test and documentation for archive /.gitattributes export-ignore /.gitignore export-ignore /.scrutinizer.yml export-ignore /.travis.yml export-ignore /phpunit.xml.dist export-ignore /tests export-ignore /docs export-ignore ================================================ FILE: .github/CONTRIBUTING.md ================================================ Contributing to Yii2 ==================== - [Report an issue](https://github.com/yiisoft/yii2/blob/master/docs/internals/report-an-issue.md) - [Translate documentation or messages](https://github.com/yiisoft/yii2/blob/master/docs/internals/translation-workflow.md) - [Give us feedback or start a design discussion](https://forum.yiiframework.com/c/yii-2-0/general-discussions/16) - [Contribute to the core code or fix bugs](https://github.com/yiisoft/yii2/blob/master/docs/internals/git-workflow.md) ================================================ FILE: .github/FUNDING.yml ================================================ # These are supported funding model platforms open_collective: yiisoft ================================================ FILE: .github/ISSUE_TEMPLATE.md ================================================ ### What steps will reproduce the problem? ### What's expected? ### What do you get instead? ### Additional info | Q | A | ---------------- | --- | Yii vesion | | PHP version | | Operating system | ================================================ FILE: .github/PULL_REQUEST_TEMPLATE.md ================================================ | Q | A | ------------- | --- | Is bugfix? | ✔️/❌ | New feature? | ✔️/❌ | Breaks BC? | ✔️/❌ | Fixed issues | ================================================ FILE: .github/SECURITY.md ================================================ # Security Policy Please use the [security issue form](https://www.yiiframework.com/security) to report to us any security issue you find in Yii. DO NOT use the issue tracker or discuss it in the public forum as it will cause more damage than help. Please note that as a non-commercial OpenSource project we are not able to pay bounties at the moment. ================================================ FILE: .gitignore ================================================ # phpstorm project files .idea # netbeans project files nbproject # zend studio for eclipse project files .buildpath .project .settings # windows thumbnail cache Thumbs.db # composer composer.phar /vendor /composer.lock # Mac DS_Store Files .DS_Store # phpunit itself is not needed phpunit.phar # local phpunit config /phpunit.xmls ================================================ FILE: Bootstrap.php ================================================ * @since 2.0 */ class Bootstrap implements BootstrapInterface { /** * @inheritdoc */ public function bootstrap($app) { if ($app instanceof \yii\console\Application) { $app->controllerMap['shell'] = ArrayHelper::merge([ 'class' => 'yii\shell\ShellController', 'shellConfig' => [ 'updateCheck' => 'never', ], ], isset($app->controllerMap['shell']) ? $app->controllerMap['shell'] : []); } } } ================================================ FILE: CHANGELOG.md ================================================ Yii Framework 2 Shell extension Change Log ========================================== 2.0.7 under development ----------------------- - Chg #43: Version bump for symfony/var-dumper dependency (Jiminald) 2.0.6 February 13, 2025 ----------------------- - Enh #32: Disable update check, allow configuring PsySH (flaviovs) - Enh #40: Allow psy/psysh ^0.12.0 additionally (JasonStainton) 2.0.5 September 04, 2022 ------------------------ - Enh #28: Allow psy/psysh ^0.11.0 additionally (wa1kb0y) 2.0.4 May 02, 2020 ------------------ - Enh #27: Allow psy/psysh ~0.10.3 additionally to ~0.9.3 (tobiase) 2.0.3 March 03, 2020 -------------------- - Enh #26: Add compatibility with `symfony/var-dumper` 5.x (samdark) 2.0.2 January 07, 2019 ---------------------- - Enh #19: Bump psy/psysh to ~0.9.3 (ricpelo) 2.0.1 March 26, 2018 -------------------- - Enh #10, #13: Updated psy version (kyle-mccarthy, samdark) 2.0.0 November 22, 2016 ----------------------- - Initial release. ================================================ FILE: LICENSE.md ================================================ Copyright © 2008 by Yii Software LLC (http://www.yiisoft.com) All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of Yii Software LLC nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ================================================ FILE: README.md ================================================

Interactive Shell Extension for Yii 2


This extension provides an interactive shell for [Yii framework 2.0](https://www.yiiframework.com) based on [psysh](https://psysh.org/). For license information check the [LICENSE](LICENSE.md)-file. [![Latest Stable Version](https://poser.pugx.org/yiisoft/yii2-shell/v/stable.png)](https://packagist.org/packages/yiisoft/yii2-shell) [![Total Downloads](https://poser.pugx.org/yiisoft/yii2-shell/downloads.png)](https://packagist.org/packages/yiisoft/yii2-shell) Installation ------------ The preferred way to install this extension is through [composer](https://getcomposer.org/download/). Either run composer require yiisoft/yii2-shell or add ```json "yiisoft/yii2-shell": "~2.0.0" ``` to the `require` 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 `Yii::$app`. Additionally you have access to all your and your dependencies' classes. See [psysh's website](https://psysh.org/#features) for a list of available features. Configuration ------------- You can configure the PsySH shell by setting options via the `shellConfig` variable in the controller, i.e. add this to your console application configuration: ``` 'controllerMap' => [ 'shell' => [ 'shellConfig' => [ 'updateCheck' => 'weekly', 'verbosity' => \Psy\Configuration::VERBOSITY_VERBOSE, ], ], ], ``` See https://github.com/bobthecow/psysh/wiki/Config-options for a list of PsySH configurable options. **Note**: `updateCheck` is explictly set to _never_ by yii2-shell. All other PsySH options use default values. Screenshot ---------- The following screenshot shows a usage example: ![Usage example of Yii2 shell](screenshot.png) ================================================ FILE: ShellController.php ================================================ * @since 2.0 */ class ShellController extends Controller { /** * @var array include file(s) before starting tinker shell */ public $include = []; /** * @var array PsySH shell configuration array * @since 2.0.6 */ public $shellConfig = []; /** * @inheritdoc */ public function options($actionID) { return array_merge(parent::options($actionID), [ 'include' ]); } /** * Runs interactive shell */ public function actionIndex() { $config = new Configuration; $config->loadConfig($this->shellConfig); $config->getPresenter()->addCasters( $this->getCasters() ); $shell = new Shell($config); $shell->setIncludes($this->include); $shell->run(); } /** * @return array casters for psysh */ protected function getCasters() { return [ 'yii\db\ActiveRecord' => 'yii\shell\YiiCaster::castModel', ]; } } ================================================ FILE: YiiCaster.php ================================================ * @since 2.0 */ class YiiCaster { /** * Get an array representing the properties of a model. * * @param \yii\db\ActiveRecord $model * @return array */ public static function castModel(ActiveRecord $model) { $attributes = array_merge( $model->getAttributes(), $model->getRelatedRecords() ); $results = []; foreach ($attributes as $key => $value) { $results[Caster::PREFIX_VIRTUAL.$key] = $value; } return $results; } } ================================================ FILE: composer.json ================================================ { "name": "yiisoft/yii2-shell", "description": "The interactive shell extension for Yii framework", "keywords": [ "yii2", "shell" ], "type": "yii2-extension", "license": "BSD-3-Clause", "support": { "issues": "https://github.com/yiisoft/yii2-shell/issues", "forum": "https://www.yiiframework.com/forum/", "wiki": "https://www.yiiframework.com/wiki/", "irc": "ircs://irc.libera.chat:6697/yii", "source": "https://github.com/yiisoft/yii2-shell" }, "authors": [ { "name": "Daniel Gomez Pan", "email": "pana_1990@hotmail.com" }, { "name": "Sascha Vincent Kurowski", "email": "svkurowski@gmail.com" } ], "require": { "yiisoft/yii2": "~2.0.0", "psy/psysh": "~0.9.3|~0.10.3|^0.11.0|^0.12.0", "symfony/var-dumper": "~2.7|~3.0|~4.0|~5.0|~6.0|~7.0" }, "autoload": { "psr-4": { "yii\\shell\\": "" } }, "extra": { "bootstrap": "yii\\shell\\Bootstrap", "branch-alias": { "dev-master": "2.0.x-dev" } } }