- Issue the following commands from the command line in your Yii application directory:
chmod +x shellmkdir extensions/yiishellwget -O extensions/yiishell/psysh psysh.org/psyshchmod +x extensions/yiishell/psysh
- Copy the file
init.phpbelow toextensions/yiishell/init.phpand update any paths to work with your application configuration - Copy the file
config.phpbelow toextensions/yiishell/config.php. Change or add to the config array with the options you'd like to use (available options) - Now you can start PsySH with the command
extensions/yiishell/psysh extensions/yiishell/init.php --config extensions/yiishell/config.php- Alternatively, for an easy way to start the shell, copy the
shellscript below to your application directory, then run./shell
- Alternatively, for an easy way to start the shell, copy the
Last active
August 21, 2019 10:20
-
-
Save mrdziuban/7c3cffc52c41f0bb7577 to your computer and use it in GitHub Desktop.
How to use PsySH with a Yii application
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| return array( | |
| 'eraseDuplicates' => true, | |
| 'historySize' => 100, | |
| ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| ini_set('memory_limit', -1); | |
| $yiidir = dirname(__FILE__).'/../../../yii/framework/'; | |
| $appdir = dirname(__FILE__).'/../../'; | |
| require_once($yiidir.'yii.php'); | |
| error_reporting(E_ALL ^ (E_STRICT|E_NOTICE)); | |
| $_SERVER['SCRIPT_NAME'] = '/index.php'; | |
| $_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME']; | |
| $_SERVER['SCRIPT_FILENAME'] = $yiidir.'index.php'; | |
| $_SERVER['SERVER_PORT'] = 80; | |
| $_SERVER['HTTP_HOST'] = 'localhost'; | |
| $_SERVER['SERVER_NAME'] = 'localhost'; | |
| Yii::createWebApplication($appdir.'config/main.php'); | |
| $version = Yii::getVersion(); | |
| echo <<<EOD | |
| Yii Interactive Tool v1.1 (based on Yii v{$version}) | |
| Please type 'help' for help. Type 'exit' to quit. | |
| EOD; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh -x | |
| ./extensions/yiishell/psysh ./extensions/yiishell/init.php --config ./extensions/yiishell/config.php |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for this guide! I wrote a version for Yii2 here:
https://gist.github.com/cornernote/ccf7e62d965497369185
Almost exactly the same, just copied the code from
yiicli script intoinit.phpand removed$application->run().