admin管理员组文章数量:1022769
I am using WP-CLI shell to quickly debug some code, but every time I run into a fatal
exception (e.g. undefined constants/functions) the shell exits and I lose my shell session. Is there a way to prevent this?
wp> new DoesntExist();
Fatal error: Class 'DoesntExist' not found in phar:///usr/local/bin/wp/php/WP_CLI/REPL.php(37) : eval()'d code on line 1
Shell exits..
I am using WP-CLI shell to quickly debug some code, but every time I run into a fatal
exception (e.g. undefined constants/functions) the shell exits and I lose my shell session. Is there a way to prevent this?
wp> new DoesntExist();
Fatal error: Class 'DoesntExist' not found in phar:///usr/local/bin/wp/php/WP_CLI/REPL.php(37) : eval()'d code on line 1
Shell exits..
Share Improve this question edited Nov 28, 2016 at 17:40 Damien asked Nov 28, 2016 at 16:12 DamienDamien 2414 silver badges9 bronze badges 4- Have you tried: $ wp shell --basic – prosti Commented Nov 28, 2016 at 17:34
- Yes, I have. Doesn't seem to matter. – Damien Commented Nov 28, 2016 at 17:39
- @prosti have you used Boris before with WP-CLI? Apparently that would work but I cannot find documentation aside from it being mentioned here - wp-cli/commands/shell – Damien Commented Nov 28, 2016 at 17:42
- stackoverflow/questions/18809841/… – prosti Commented Nov 28, 2016 at 17:43
1 Answer
Reset to default 4This is the default behavior of WP-CLI's built-in PHP REPL. If you look at the wp shell documentation, it shows that you can also use the Boris or PsySH PHP REPLs.
The Boris REPL does not seem to be actively maintained; however the PsySH REPL has fairly recent maintenance, and it fixes the problem that you're experiencing.
The easiest way to integrate PsySH with WP-CLI is to use the wp-cli-psysh plugin:
# Make sure WP-CLI is up to date
wp cli update
# Install the plugin
wp package install [email protected]:schlessera/wp-cli-psysh.git
After installing the plugin, running wp shell should show you a PsySH header that's similar to this:
$ wp shell
Psy Shell v0.9.9 (PHP 7.3.1-1+ubuntu18.04.1+deb.sury+1 — cli) by Justin Hileman
>>>
I am using WP-CLI shell to quickly debug some code, but every time I run into a fatal
exception (e.g. undefined constants/functions) the shell exits and I lose my shell session. Is there a way to prevent this?
wp> new DoesntExist();
Fatal error: Class 'DoesntExist' not found in phar:///usr/local/bin/wp/php/WP_CLI/REPL.php(37) : eval()'d code on line 1
Shell exits..
I am using WP-CLI shell to quickly debug some code, but every time I run into a fatal
exception (e.g. undefined constants/functions) the shell exits and I lose my shell session. Is there a way to prevent this?
wp> new DoesntExist();
Fatal error: Class 'DoesntExist' not found in phar:///usr/local/bin/wp/php/WP_CLI/REPL.php(37) : eval()'d code on line 1
Shell exits..
Share Improve this question edited Nov 28, 2016 at 17:40 Damien asked Nov 28, 2016 at 16:12 DamienDamien 2414 silver badges9 bronze badges 4- Have you tried: $ wp shell --basic – prosti Commented Nov 28, 2016 at 17:34
- Yes, I have. Doesn't seem to matter. – Damien Commented Nov 28, 2016 at 17:39
- @prosti have you used Boris before with WP-CLI? Apparently that would work but I cannot find documentation aside from it being mentioned here - wp-cli/commands/shell – Damien Commented Nov 28, 2016 at 17:42
- stackoverflow/questions/18809841/… – prosti Commented Nov 28, 2016 at 17:43
1 Answer
Reset to default 4This is the default behavior of WP-CLI's built-in PHP REPL. If you look at the wp shell documentation, it shows that you can also use the Boris or PsySH PHP REPLs.
The Boris REPL does not seem to be actively maintained; however the PsySH REPL has fairly recent maintenance, and it fixes the problem that you're experiencing.
The easiest way to integrate PsySH with WP-CLI is to use the wp-cli-psysh plugin:
# Make sure WP-CLI is up to date
wp cli update
# Install the plugin
wp package install [email protected]:schlessera/wp-cli-psysh.git
After installing the plugin, running wp shell should show you a PsySH header that's similar to this:
$ wp shell
Psy Shell v0.9.9 (PHP 7.3.1-1+ubuntu18.04.1+deb.sury+1 — cli) by Justin Hileman
>>>
本文标签: wp cliHow to prevent WPCLI shell from exiting when an exception occurs
版权声明:本文标题:wp cli - How to prevent WP-CLI shell from exiting when an exception occurs? 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745574273a2156921.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论