krvechtivy / php-console

Automatically exported from code.google.com/p/php-console
0 stars 0 forks source link

PhpConsole::start() returns $isEnabledOnClient flag #28

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
In CodeIgniter, we can override log_message function while bootstrap.
It would be great if we can use PhpConsole::start() return value to 
conditionally override this function while in development mode.

Here is what I currently used:

if (defined('ENVIRONMENT') && ENVIRONMENT == 'development') {
    require_once('PhpConsole.php');
    if (PhpConsole::start()) {
        function log_message($level = 'error', $message, $php_error = FALSE) {
            $tag = $php_error? 'fatal' : $level;
            PhpConsole::debug($message, $tag);
        }

        PhpConsole::debug("$_SERVER[REQUEST_METHOD] $_SERVER[REQUEST_URI]");
    }
}

Original issue reported on code.google.com by vira...@gmail.com on 30 Aug 2013 at 2:01

GoogleCodeExporter commented 9 years ago
I'm sorry, but I'm just don't understand what do you mean :) 

BTW, there will be new version of PHP Console with a lot of refactoring & new 
features. See http://code.google.com/p/php-console/wiki/Ch

Release will comming in September 2013

Original comment by barbushin on 30 Aug 2013 at 7:35

GoogleCodeExporter commented 9 years ago
Did you mean that you just want to get method returning $isEnabledOnClient 
flag? There will be method like this in new PHP Console version. In current 
version it's impossible to do this. You can just override method

protected static function isEnabledOnClient() {
                return isset($_COOKIE[self::clientProtocolCookie]) && $_COOKIE[self::clientProtocolCookie] == self::serverProtocol;
        }

to make it public.

Original comment by barbushin on 30 Aug 2013 at 7:42

GoogleCodeExporter commented 9 years ago
Yes, I means returning $isEnabledOnClient flag. Sorry for missing the key 
point. 

I also tried isEnabledOnClient method, but the computed value is really static 
while in a request. So I don't want to recompute it again. So returning 
$isEnabledOnClient is what I prefer.

Original comment by vira...@gmail.com on 30 Aug 2013 at 8:10

GoogleCodeExporter commented 9 years ago
This is what I do:

    public static function start($handleErrors = true, $handleExceptions = true, $sourceBasePath = null) {
        if(!self::$instance) {
            self::$instance = new PhpConsole($handleErrors, $handleExceptions, $sourceBasePath);
        }

        return self::$isEnabledOnClient;
    }

Original comment by vira...@gmail.com on 30 Aug 2013 at 8:21

GoogleCodeExporter commented 9 years ago

Original comment by barbushin on 13 Nov 2013 at 6:16