Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improvement - need of profiling nested vars #7

Closed
ichiriac opened this issue Dec 24, 2012 · 4 comments
Closed

improvement - need of profiling nested vars #7

ichiriac opened this issue Dec 24, 2012 · 4 comments

Comments

@ichiriac
Copy link
Collaborator

Hi,

I need to make some debug and inspect vars, so the simplest way is to do a vardump but it's noisy and disturbs the html, and it's not really simple to read (coz of tree of referenced objects).

Maybe you could add a sort of forp_inspect function that creates a debug structure directly in the current forp_node.

define('DBG_ENABLED', 
  function_exists('forp_start') && (forp_start() || true)
);
function foo() {
   DBG_ENABLED && forp_inspect('$my_var", $my_var);
   ....
}

This structure could be serialized like this :

{
  ...
  "inspect": {
     "$my_var" : {
        "type" : "array",
        "size" : 5,
        "value" : { 
             ... inner list of debug ...
         }
      },
     "$this" : {
        "type": "object",
        "class" : "....object class name",
        "properties" : {
            "foo" : {
                "level": "public",
                "type" ...
            }, 
           "parent": {
               "level" : "private",
               "type": "object",
               "class": "....",
               "reference": true // avoid inspecting referenced objects (too nesting)
           }
        }
     }
   }
}

With the forp GUI the exploration of trees of properties and nested arrays will be much greater than showing all informations expanded like in a var_dump or print_r.

It could also be usefull for debugging functions parameters like you do with the @ProfileCaption annotation but with more details -

@ProfileInspect("$var", 1) will add to the inspector the entry $var with the content of the first parameter.

@aterrien
Copy link
Owner

I just released a first implementation of forp_inspect.
I plan to add minor features in the next days.

@wojons
Copy link

wojons commented Apr 19, 2013

wanted to know if we can get the inspect do run for all the inputs of functions, this would be great so i dont need to support forp and xdebug.

@ichiriac
Copy link
Collaborator Author

this function is now available with forp_inspect by using json_encode(forp_dump()); for output.

Sample code :

forp_start();
forp_inspect('$_SERVER', $_SERVER);
forp_inspect('$_GET', $_GET);
forp_inspect('$_POST', $_POST);
forp_inspect('$_COOKIES', $_COOKIES);
register_shutdown_function(function() {
echo '<script src="http://aterrien.github.io/forp-ui/javascripts/forp.min.js?v2"></script>';
echo '<script>var $f = new forp.Controller(); $f.setStack(';
echo json_encode(forp_dump());
echo ').run();</script>';
});

Work in progress to enable forp_json to output inspect stack

@ichiriac
Copy link
Collaborator Author

ichiriac commented Jan 3, 2014

I close this inactive thread - see #8

@ichiriac ichiriac closed this as completed Jan 3, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants