Code Monkey home page Code Monkey logo

wp-php-console's Introduction

WP PHP Console

GitHub version Scrutinizer Code Quality

An implementation of PHP Console as a WordPress plugin. Use Chrome Dev Tools to debug your WordPress installation!

Description

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.

Download from WordPress.org

Installation

Note: you will at least PHP 5.6.0 or above installed on your machine or server to run this plugin.

  1. First, install Google Chrome extension PHP Console from the Chrome WebStore. Make sure the PHP Console Chrome extension is enabled through chrome://extensions/.

    Important Note

    If the Google Chrome extension is not available on the Chrome Web Store, you can manually install it from source.

  2. Then, add this plugin to your WordPress installation either by:

  • Installing it as any other WordPress plugin from your WordPress admin Plugins page (Add New).

  • Downloading a copy from WordPress.org and uploading it in wp-php-console directory into your wp-content/plugins/ directory or corresponding plugins directory in your installation. You can also do this from the WordPress plugins installation admim dashboard pages.

  • Note: If you decide to git clone this repository instead, you will need composer install to install its dependencies first, or it won't work in WordPress as it is.

  1. Activate the plugin through the Plugins admin page in WordPress

  2. In the Settings menu go to WP PHP Console:

  • Enter a password for the Eval Terminal (this setting is needed or the terminal feature simply won't work).

  • You can also set other options (see inline instructions or read below).

Options

Allow only on SSL

Forces PHP Console to connect on a SSL connection only (of course then if you don't actually have SSL (https), PHP Console simply won't work).

Allowed IP Masks

You can secure your server by specifying IP addresses to restrict the accessibility from the Eval Terminal (a single address eg. 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

Usage

After you entered WP PHP Plugin password, your browser address bar should show a yellow "key" icon, which, if clicked, will prompt for the password you have set earlier. The "key" icon will change into a "terminal" icon, click on it to open the PHP Console eval & options form.

After entering the correct password, you can use the Eval Terminal in the PHP Console eval & options form and run any PHP code from it, including WordPress's own functions: enter one or more lines of PHP code in the black Eval terminal screen, press Ctrl+Enter and see the result in Chrome Dev Tools JavaScript console. The result includes the output, the return value and the net server execution time.

In your PHP code on the Server, you can call PHP Console debug statements like PC::debug( $var, $tag ) to display PHP variables in the JavaScript console and optionally filter selected tags through the PHP Console eval & options form opened from the address bar in your browser.

In the JavaScript console you will see printed any PC::debug() information, PHP errors, warnings, notices with optional stack trace, which will be useful to debug your plugin or theme.

wp-php-console's People

Contributors

gitter-badger avatar polfo avatar unfulvio avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

wp-php-console's Issues

Plugin breaks theme/plugin editor save

This is a fantastic plugin for debugging, but unfortunately it breaks some core WordPress functionality. When this plugin is active, it's not possible to save php-files through the WordPress theme/plugin editor. The save request always times out after 10 seconds . (Non-php files can be saved without problems.)

This issue also shows up in WordPress' Health Check as a failed loopback request:

The loopback request to your site failed, this may prevent WP_Cron from working, along with theme and plugin editors.
Error encountered: (0) cURL error 28: Operation timed out after 10000 milliseconds with 0 bytes received

Cannot send session cache limiter - headers already sent

Wordpress WPMU: 4.2.2
Theme: Twenty Fifteen
PHP: 5.4.40
All other plugins deactivated.

This error occurs at the bottom of the page:

Cannot send session cache limiter - headers already sent (output started at /home/odio/public_html/wp-includes/functions.php:3282) in /home/odio/public_html/wp-content/plugins/wp-php-console/vendor/php-console/php-console/src/PhpConsole/Storage/Session.php on line 25

In the Settings menu, the WP PHP Console isn't there, but the above error message is at the bottom of the page.

fatal error

Got the following error when I tried to activate the plugin

    Notice: Undefined index: args in /vagrant/wp/wp-includes/functions.php
    on line 4311

    Warning: require_once(/vagrant/content/plugins/wp-php-console-
    master/lib/php-console/src/PhpConsole/__autoload.php): failed to open
    stream: No such file or directory in /vagrant/content/plugins/wp-php-
    console-master/wp-php-console.php on line 28

    Fatal error: require_once(): Failed opening required
    '/vagrant/content/plugins/wp-php-console-master/lib/php-
    console/src/PhpConsole/__autoload.php'
    (include_path='.:/usr/share/php:/usr/share/pear') in
    /vagrant/content/plugins/wp-php-console-master/wp-php-console.php on
    line 28

The vagrant installation is https://github.com/Chassis/Chassis

Wrong PHP Console eval request signature

When I try to execute from the console, I get the error indicating that the request signature does not match the signature generated by the php console library (in Auth.php).

Plugin is installed. Password is set. I am receiving E_NOTICE, E_WARNING, etc. in my console. So I know it is working.

I tried the IP address mask field (, *..., my own IP, blank, etc.) - they all result in the same error

I am able to use http://162.250.145.84/php-console/examples/features/eval_terminal.php without issues, so the chrome extension is working properly.

I tried two different wordpress installs on two different hosting providers, same error.

version 1.3.9

Hi there ,

I got the following fatal error:

Fatal error: Uncaught exception 'Exception' with message 'PhpConsole\Connector::setPostponeStorage can be called only before PhpConsole\Connector::getInstance()' in plugins\wp-php-console\vendor\php-console\php-console\src\PhpConsole\Connector.php:80 Stack trace: #0 plugins\wp-php-console\lib\class-wp-php-console.php(73):

Thanks

Load plugin on plugins_loaded instead of init.

Hi,

We are getting into some cases where PHP console is failed to collect the errors.
It is even throwing undefined PC class error if used as an open statement (without any callbacks) or any hook above 'init'.

I think it's better to move it on plugins_loaded with priority in negative as it might catch errors that cause during loading of plugins/themes.
What do you think?

PHP Warning: session_start(): Cannot send session cache limiter - headers already sent

this seems an error that creeped out again

PHP Warning:  session_start(): Cannot send session cache limiter - headers already sent (output started at /...path.../wp-includes/functions.php:3549) in /...path.../wp-content/plugins/wp-php-console/vendor/php-console/php-console/src/PhpConsole/Storage/Session.php on line 25

does not inhibit plugin functionalities and error is suppressed in Chrome console... but will show up and pollute logs

Update for PHP > 8.0

Hello, I would like to ask if you could make a small update of the plugin for the php version above version 8, now the plugin works with version 8. But it returns a lot of warnings to the page

Warning: Private methods cannot be final as they are never overridden by other classes in D:\OpenServer\domains\fansy.loc\web\app\plugins\wp-php-console\vendor\php-console\php-console\src\PhpConsole\Connector.php on line 101

Deprecated: Required parameter $args follows optional parameter $key in D:\OpenServer\domains\fansy.loc\web\app\plugins\wp-php-console\vendor\php-console\php-console\src\PhpConsole\Connector.php on line 377

Warning: Private methods cannot be final as they are never overridden by other classes in D:\OpenServer\domains\fansy.loc\web\app\plugins\wp-php-console\vendor\php-console\php-console\src\PhpConsole\Auth.php on line 106

Warning: Private methods cannot be final as they are never overridden by other classes in D:\OpenServer\domains\fansy.loc\web\app\plugins\wp-php-console\vendor\php-console\php-console\src\PhpConsole\Handler.php on line 55

E_NOTICE Undefined offset: 0

Hi there,

I'm getting the following notice:

E_NOTICE Undefined offset: 0

/wp-includes/capabilities.php 127.

Thanks

How to avoid "Fatal error: Uncaught Error: Class 'PC' not found"

Hi Fulvio,

First I'd like to thank you for creating such a useful plugin for PHP developers in WP. I've read in your plugin page the reason why I'm getting the error Fatal error: Uncaught Error: Class 'PC' not found, but I could not understand 100% how to solve it.

When you write that we can use the following code bellow, where exactly should I place it in?

// 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();

getting fatal error when activating the plugin

Hey,
this is what i get over and over again:

Warning: require_once(DIR/composer/autoload_real.php) [function.require-once]: failed to open stream: No such file or directory in /home/talgui5/public_html/moti/wp-content/plugins/wp-php-console-master/vendor/autoload.php on line 5

Fatal error: require_once() [function.require]: Failed opening required 'DIR/composer/autoload_real.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/talgui5/public_html/moti/wp-content/plugins/wp-php-console-master/vendor/autoload.php on line 5

Enhancement: Additional PHP Console Options

It would be nice to have an option in WP PHP Console Settings to activate this code:

// reduce displayed SourcesPath
$connector = PhpConsole\Connector::getInstance();
$connector->setSourcesBasePath($_SERVER['DOCUMENT_ROOT']);

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.