开发者 | nekojira |
---|---|
更新时间 | 2020年11月9日 11:28 |
捐献地址: | 去捐款 |
PHP版本: | 5.6 及以上 |
WordPress版本: | 5.5.3 |
版权: | GPLv3 or later |
版权网址: | 版权信息 |
PHP Console allows you to handle PHP errors & exceptions, dump variables, execute PHP code remotely and many other things using Google Chrome extension PHP Console and PHP Console server library.This implementation of PHP Console is a handy tool to make it easier to test on the fly any WordPress specific function or class (including those introduced by your active theme and plugins!) from a terminal and inspect results, catch errors and warnings with complete call stack trace straight from the Chrome JavaScript console. In other words, besides debugging, you can execute PHP or WordPress-specific PHP code straight from the terminal and print PHP variables in Chrome Dev Tools JavaScript console along with your normal JavaScript debugging and testing. Keep everything in one place, without leaving the browser to check for your logs or writing temporary PHP test code on a PHP file and refresh your browser page. Note: PHP version 5.6.0 or above is required to use this plugin. For support and pull requests, please refer to WP PHP Console GitHub repo and read the instructions there - thank you.
Add New
)
wp-php-console
directory into your wp-content/plugins/
directory or corresponding plugins directory in your installation
Plugins
admin page in WordPress
Settings
menu go to WP PHP Console
:
192.168.0.4
or an address mask eg. 192.168.*.*
or multiple IPs, comma separated 192.168.1.22,192.168.1.24,192.168.3.*
). In case of having issues connecting with the Remote PHP Eval Terminal, try leaving this blank.
Register PC Class
Tick this option to register PC
in the global PHP namespace. This allows to write PC::debug($var, $tag)
or PC::magic_tag($var)
instructions in PHP to inspect $var
in the JavaScript console.
Show Call Stack
Tick this option to see the call stack when PHP Console server writes to the JavaScript console.
Short Path Names
Tick this checkbox to shorten PHP Console error sources and traces paths in the JavaScript console. E.g. paths like /server/path/to/document/root/WP/wp-admin/admin.php:38
will be displayed as /WP/wp-admin/admin.php:38
No, but it makes use of Sergey's PHP Console library as it is.
No it doesn't, unless PHP Console browser extension is ported, for example, as a Firefox add-on.
You can but it is probably not a good idea. You should do your debugging and testing on a development/testing environment on a staging server or local machine. Likewise, you normally wouldn't want to turn on PHP error reporting or set WP_DEBUG to true in a live site as you wouldn't want to display error information to public. Furthermore, PHP Console allows execution of any remote PHP code through terminal - for this you can set a strong password and restrict the IP address range to access the terminal, but still it's not advisable. Besides putting your site at risk, you will also add more load to your server.
Generally no, WP PHP Console will intercept those. However, it's always a good idea to keep an eye on the logs too. Furthermore, WP PHP Console is unable to catch many server errors that result in a 500 error code on the browser. For those you may have traces left in the debug.log file.
The JavaScript console prints PHP variables as JavaScript variables. Associative PHP arrays such as ['key1' => 'var2', 'key2' => 'var2', ... ]
are shown as objects; automatically indexed arrays like [ 'var1', 'var2', ... ]
are shown as arrays.
PC::debug( $my_var, $my_tag )
can only be called after the WordPress core included the WP PHP Console plugin.
You could move your debug code or either do something like
// delay use of PC class until WP PHP Console plugin is included add_action( 'plugins_loaded', function () use ( $my_var ) { // send $my_var with tag 'my_tag' to the JavaScript console through PHP Console Server Library and PHP Console Chrome Plugin PC::my_tag( $my_var ); });
or
`
// PHP Console autoload
require_once dirname( FILE ) . '/wp-php-console/vendor/autoload.php';
// make PC class available in global PHP scope
if ( ! class_exists( 'PC', false ) ) PhpConsole\Helper::register();
// send $my_var with tag 'my_tag' to the JavaScript console through PHP Console Server Library and PHP Console Chrome Plugin
PC::my_tag( $my_var );
`
Cannot send session cache limiter - headers already sent