PHP Classes

PHP Web Console: Execute PHP commands on a console Web page

Recommend this page to a friend!
  Info   Example   Screenshots   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
StarStarStar 57%Total: 268 All time: 7,738 This week: 51Up
Version License PHP version Categories
php-web-console 1.0Public Domain5.4HTML, PHP 5, Debug, Logging
Description 

Author

This class can Execute PHP commands on a console web page inspired by the Chromium JavaScript console.

It can execute given PHP code and other console commands and stores HTML to display the results on session variables.

The class can output the responses of the requested console commands as response to AJAX requests that update the current page with the commands output for the users to see on the web page.

The other console commands that it supports are log to display an arbitrary message, alert to display a message in an alert dialog on the browser, backtrace to show the function call backtrace.

Picture of Matthew Knowlton
  Performance   Level  
Innovation award
Innovation award
Nominee: 4x

Winner: 1x

 

Example

<?php
require_once('PHPConsole.class.php');

if(isset(
$_POST['command']) && $_POST['command'] != ''){
   
PHPConsole::run($_POST['command']);
    exit();
}
?>

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script>
setTimeout(function(){
    $('#submit').click(function(){
        if($('#command').val() == '') return;
        $.post('console.example1.php',{'command': $('#command').val()},function(r){
            $('#command').val('');
        });
    });
   
    $('#stop').click(function(){
        $.post('console.example1.php',{'command': 'exit();'},function(r){
            $('#command, #submit, #stop').hide();
            $('#restart').show();
           
        });
    });
   
    $('#restart').click(function(){
        top.location.reload();
    });
},1000);
</script>

<div>
    <input id="command" name="command"/>
    <button id="submit">Submit</button>
    <button id="stop">Stop</button>
    <button id="restart" style="display:none;">Start</button>
    <br/>
</div>

<?php
PHPConsole
::printDisplay();
?>


Screenshots (1)  
  • PHPConsole.jpg
  Files folder image Files (4)  
File Role Description
Plain text file PHPConsole.class.php Class PHPConsole Class
Accessible without login Plain text file console.example1.php Example Example of a PHP console setup
Accessible without login Plain text file console.example2.php Example Example of PHPConsole being used for logging by an separate script.

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 0%
Total:268
This week:0
All time:7,738
This week:51Up
 User Ratings  
 
 All time
Utility:83%StarStarStarStarStar
Consistency:83%StarStarStarStarStar
Documentation:-
Examples:75%StarStarStarStar
Tests:-
Videos:-
Overall:57%StarStarStar
Rank:1686