[
  {
    "path": ".editorconfig",
    "content": "# editorconfig.org\n\nroot = true\n\n[*]\ncharset = utf-8\nend_of_line = lf\ninsert_final_newline = true\nindent_style = space\nindent_size = 4\ntrim_trailing_whitespace = true\n\n[*.md]\ntrim_trailing_whitespace = false\n"
  },
  {
    "path": ".gitattributes",
    "content": "# Ignore all test and documentation for archive\n/.gitattributes     export-ignore\n/.gitignore         export-ignore\n/.scrutinizer.yml   export-ignore\n/.travis.yml        export-ignore\n/phpunit.xml.dist   export-ignore\n/tests              export-ignore\n/docs               export-ignore\n"
  },
  {
    "path": ".github/CONTRIBUTING.md",
    "content": "Contributing to Yii2\n====================\n\n- [Report an issue](https://github.com/yiisoft/yii2/blob/master/docs/internals/report-an-issue.md)\n- [Translate documentation or messages](https://github.com/yiisoft/yii2/blob/master/docs/internals/translation-workflow.md)\n- [Give us feedback or start a design discussion](https://forum.yiiframework.com/c/yii-2-0/general-discussions/16)\n- [Contribute to the core code or fix bugs](https://github.com/yiisoft/yii2/blob/master/docs/internals/git-workflow.md)\n"
  },
  {
    "path": ".github/FUNDING.yml",
    "content": "# These are supported funding model platforms\n\nopen_collective: yiisoft\n"
  },
  {
    "path": ".github/ISSUE_TEMPLATE.md",
    "content": "<!--\nPlease use this issue tracker for bugs and feature requests only. In case you need support please use one of\nYii communities listed at https://github.com/yiisoft/yii2/wiki/communities\n-->\n\n### What steps will reproduce the problem?\n\n### What's expected?\n\n### What do you get instead?\n\n\n### Additional info\n\n| Q                | A\n| ---------------- | ---\n| Yii vesion       |\n| PHP version      |\n| Operating system |\n"
  },
  {
    "path": ".github/PULL_REQUEST_TEMPLATE.md",
    "content": "| Q             | A\n| ------------- | ---\n| Is bugfix?    | ✔️/❌\n| New feature?  | ✔️/❌\n| Breaks BC?    | ✔️/❌\n| Fixed issues  | <!-- comma-separated list of tickets # fixed by the PR, if any -->\n"
  },
  {
    "path": ".github/SECURITY.md",
    "content": "# Security Policy\n\nPlease use the [security issue form](https://www.yiiframework.com/security) to report to us any security issue you find in Yii.\nDO NOT use the issue tracker or discuss it in the public forum as it will cause more damage than help.\n\nPlease note that as a non-commercial OpenSource project we are not able to pay bounties at the moment.\n"
  },
  {
    "path": ".gitignore",
    "content": "# phpstorm project files\n.idea\n\n# netbeans project files\nnbproject\n\n# zend studio for eclipse project files\n.buildpath\n.project\n.settings\n\n# windows thumbnail cache\nThumbs.db\n\n# composer\ncomposer.phar\n/vendor\n/composer.lock\n\n# Mac DS_Store Files\n.DS_Store\n\n# phpunit itself is not needed\nphpunit.phar\n# local phpunit config\n/phpunit.xmls\n"
  },
  {
    "path": "Bootstrap.php",
    "content": "<?php\n/**\n * @link https://www.yiiframework.com/\n * @copyright Copyright (c) 2008 Yii Software LLC\n * @license https://www.yiiframework.com/license/\n */\n\nnamespace yii\\shell;\n\nuse yii\\base\\BootstrapInterface;\nuse yii\\helpers\\ArrayHelper;\n\n/**\n * Class Bootstrap\n *\n * @author Sascha Vincent Kurowski <svkurowski@gmail.com>\n * @since 2.0\n */\nclass Bootstrap implements BootstrapInterface\n{\n    /**\n     * @inheritdoc\n     */\n    public function bootstrap($app)\n    {\n        if ($app instanceof \\yii\\console\\Application) {\n            $app->controllerMap['shell'] = ArrayHelper::merge([\n                'class' => 'yii\\shell\\ShellController',\n                'shellConfig' => [\n                    'updateCheck' => 'never',\n                ],\n            ], isset($app->controllerMap['shell']) ? $app->controllerMap['shell'] : []);\n        }\n    }\n}\n"
  },
  {
    "path": "CHANGELOG.md",
    "content": "Yii Framework 2 Shell extension Change Log\n==========================================\n\n2.0.7 under development\n-----------------------\n\n- Chg #43: Version bump for symfony/var-dumper dependency (Jiminald)\n\n\n2.0.6 February 13, 2025\n-----------------------\n\n- Enh #32: Disable update check, allow configuring PsySH (flaviovs)\n- Enh #40: Allow psy/psysh ^0.12.0 additionally (JasonStainton)\n\n\n2.0.5 September 04, 2022\n------------------------\n\n- Enh #28: Allow psy/psysh ^0.11.0 additionally (wa1kb0y)\n\n\n2.0.4 May 02, 2020\n------------------\n\n- Enh #27: Allow psy/psysh ~0.10.3 additionally to ~0.9.3 (tobiase)\n\n\n2.0.3 March 03, 2020\n--------------------\n\n- Enh #26: Add compatibility with `symfony/var-dumper` 5.x (samdark)\n\n\n2.0.2 January 07, 2019\n----------------------\n\n- Enh #19: Bump psy/psysh to ~0.9.3 (ricpelo)\n\n\n2.0.1 March 26, 2018\n--------------------\n\n- Enh #10, #13: Updated psy version (kyle-mccarthy, samdark)\n\n\n2.0.0 November 22, 2016\n-----------------------\n\n- Initial release.\n\n"
  },
  {
    "path": "LICENSE.md",
    "content": "Copyright © 2008 by Yii Software LLC (http://www.yiisoft.com)\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions\nare met:\n\n * Redistributions of source code must retain the above copyright\n   notice, this list of conditions and the following disclaimer.\n * Redistributions in binary form must reproduce the above copyright\n   notice, this list of conditions and the following disclaimer in\n   the documentation and/or other materials provided with the\n   distribution.\n * Neither the name of Yii Software LLC nor the names of its\n   contributors may be used to endorse or promote products derived\n   from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n\"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\nLIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS\nFOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE\nCOPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,\nINCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,\nBUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\nCAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\nLIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN\nANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\nPOSSIBILITY OF SUCH DAMAGE.\n"
  },
  {
    "path": "README.md",
    "content": "<p align=\"center\">\n    <a href=\"https://github.com/yiisoft\" target=\"_blank\">\n        <img src=\"https://avatars0.githubusercontent.com/u/993323\" height=\"100px\">\n    </a>\n    <h1 align=\"center\">Interactive Shell Extension for Yii 2</h1>\n    <br>\n</p>\n\nThis extension provides an interactive shell for [Yii framework 2.0](https://www.yiiframework.com) based on [psysh](https://psysh.org/).\n\nFor license information check the [LICENSE](LICENSE.md)-file.\n\n[![Latest Stable Version](https://poser.pugx.org/yiisoft/yii2-shell/v/stable.png)](https://packagist.org/packages/yiisoft/yii2-shell)\n[![Total Downloads](https://poser.pugx.org/yiisoft/yii2-shell/downloads.png)](https://packagist.org/packages/yiisoft/yii2-shell)\n\n\nInstallation\n------------\n\nThe preferred way to install this extension is through [composer](https://getcomposer.org/download/).\n\nEither run\n\n    composer require yiisoft/yii2-shell\n\nor add\n\n```json\n\"yiisoft/yii2-shell\": \"~2.0.0\"\n```\n\nto the `require` section of your composer.json.\n\n\nUsage\n-----\n\nAfter installation, you will be able to run the interactive shell via command line:\n\n```\n# Change path to your application's root directory\ncd path/to/myapp\n\n# Start the interactive shell\n./yii shell\n```\n\nYou can access the application object using `Yii::$app`. Additionally you have access to all your and your dependencies' classes.\n\nSee [psysh's website](https://psysh.org/#features) for a list of available features.\n\n\nConfiguration\n-------------\n\nYou can configure the PsySH shell by setting options via the `shellConfig` variable in the controller, i.e. add this to your console application configuration:\n\n\n```\n'controllerMap' => [\n    'shell' => [\n        'shellConfig' => [\n            'updateCheck' => 'weekly',\n            'verbosity' => \\Psy\\Configuration::VERBOSITY_VERBOSE,\n        ],\n    ],\n],\n```\n\nSee https://github.com/bobthecow/psysh/wiki/Config-options for a list of PsySH configurable options.\n\n**Note**: `updateCheck` is explictly set to _never_ by yii2-shell. All other PsySH options use default values.\n\n\nScreenshot\n----------\n\nThe following screenshot shows a usage example:\n\n![Usage example of Yii2 shell](screenshot.png)\n"
  },
  {
    "path": "ShellController.php",
    "content": "<?php\n/**\n * @link https://www.yiiframework.com/\n * @copyright Copyright (c) 2008 Yii Software LLC\n * @license https://www.yiiframework.com/license/\n */\n\nnamespace yii\\shell;\n\nuse yii\\console\\Controller;\nuse Psy\\Shell;\nuse Psy\\Configuration;\n\n/**\n * Runs interactive shell. That is especially useful when developing an application and you want to try\n * some method of your code.\n *\n * @author Daniel Gomez Pan <pana_1990@hotmail.com>\n * @since 2.0\n */\nclass ShellController extends Controller\n{\n    /**\n     * @var array include file(s) before starting tinker shell\n     */\n    public $include = [];\n    /**\n     * @var array PsySH shell configuration array\n     * @since 2.0.6\n     */\n    public $shellConfig = [];\n\n\n    /**\n     * @inheritdoc\n     */\n    public function options($actionID)\n    {\n        return array_merge(parent::options($actionID), [\n            'include'\n        ]);\n    }\n\n    /**\n     * Runs interactive shell\n     */\n    public function actionIndex()\n    {\n        $config = new Configuration;\n        $config->loadConfig($this->shellConfig);\n        $config->getPresenter()->addCasters(\n            $this->getCasters()\n        );\n        $shell = new Shell($config);\n        $shell->setIncludes($this->include);\n        $shell->run();\n    }\n\n    /**\n     * @return array casters for psysh\n     */\n    protected function getCasters()\n    {\n        return [\n            'yii\\db\\ActiveRecord' => 'yii\\shell\\YiiCaster::castModel',\n        ];\n    }\n}\n"
  },
  {
    "path": "YiiCaster.php",
    "content": "<?php\n/**\n * @link https://www.yiiframework.com/\n * @copyright Copyright (c) 2008 Yii Software LLC\n * @license https://www.yiiframework.com/license/\n */\n\nnamespace yii\\shell;\n\nuse Symfony\\Component\\VarDumper\\Caster\\Caster;\nuse yii\\db\\ActiveRecord;\n\n/**\n * YiiCaster provides wrapper for casters of psysh\n *\n * @author Daniel Gomez Pan <pana_1990@hotmail.com>\n * @since 2.0\n */\nclass YiiCaster\n{\n    /**\n     * Get an array representing the properties of a model.\n     *\n     * @param \\yii\\db\\ActiveRecord $model\n     * @return array\n     */\n    public static function castModel(ActiveRecord $model)\n    {\n        $attributes = array_merge(\n            $model->getAttributes(), $model->getRelatedRecords()\n        );\n        $results = [];\n        foreach ($attributes as $key => $value) {\n            $results[Caster::PREFIX_VIRTUAL.$key] = $value;\n        }\n        return $results;\n    }\n}\n"
  },
  {
    "path": "composer.json",
    "content": "{\n    \"name\": \"yiisoft/yii2-shell\",\n    \"description\": \"The interactive shell extension for Yii framework\",\n    \"keywords\": [\n        \"yii2\",\n        \"shell\"\n    ],\n    \"type\": \"yii2-extension\",\n    \"license\": \"BSD-3-Clause\",\n    \"support\": {\n        \"issues\": \"https://github.com/yiisoft/yii2-shell/issues\",\n        \"forum\": \"https://www.yiiframework.com/forum/\",\n        \"wiki\": \"https://www.yiiframework.com/wiki/\",\n        \"irc\": \"ircs://irc.libera.chat:6697/yii\",\n        \"source\": \"https://github.com/yiisoft/yii2-shell\"\n    },\n    \"authors\": [\n        {\n            \"name\": \"Daniel Gomez Pan\",\n            \"email\": \"pana_1990@hotmail.com\"\n        },\n        {\n            \"name\": \"Sascha Vincent Kurowski\",\n            \"email\": \"svkurowski@gmail.com\"\n        }\n    ],\n    \"require\": {\n        \"yiisoft/yii2\": \"~2.0.0\",\n        \"psy/psysh\": \"~0.9.3|~0.10.3|^0.11.0|^0.12.0\",\n        \"symfony/var-dumper\": \"~2.7|~3.0|~4.0|~5.0|~6.0|~7.0\"\n    },\n    \"autoload\": {\n        \"psr-4\": {\n            \"yii\\\\shell\\\\\": \"\"\n        }\n    },\n    \"extra\": {\n        \"bootstrap\": \"yii\\\\shell\\\\Bootstrap\",\n        \"branch-alias\": {\n            \"dev-master\": \"2.0.x-dev\"\n        }\n    }\n}\n"
  }
]