Is there a way to copy the data structure from the Variables window in the debugger?

When debugging in PhpStorm, I know that you can right-click on a variable in the Variables panel and select the Copy Value item in the context menu. Is there a way to copy a data structure like an array or an object?

$_GET = {array} [1] someVariable = "Hello this is a value, and it happens to be a string" anotherVar = "What is this string" 

If I right-click on 'someVariable' and select 'Copy Value', I will have a line in my clipboard.

If I right-click on a row with an array and select "Copy value", I get "[1]" in my clipboard.

I would really like it when I right-clicked and “Copy value” in the array to have something like this in my clipboard:

 '[ 'someVariable' = 'Hello this is a value, and it happens to be a string', 'anotherVar' = 'What is this string ]' 

Any ideas, or should someone make this plugin?;)

+8
phpstorm
source share
2 answers

Currently impossible.

Please see / vote for this ticket to be notified of progress: http://youtrack.jetbrains.com/issue/WI-5693

+3
source share

Starting with PhpStorm version 9.0.0 (released July 8, 2015):

  • When debugging in PhpStorm, right-click on a variable in the Variables area and select the Copy Value As ... context menu item to copy the variable as a result of one of print_r , var_export or json_encode .

With PhpStorm <9.0.0, I used the following trick (PhpStorm 8.0.2):

  • When debugging in PhpStorm, right-click on a variable in the Variables area and select the "Evaluate Expression ..." context menu item.
  • The expression expression opens with your variable in the "Expression:" field. In your case $_GET
  • In the Expression: section, wrap your variable with the var_export function. In your case: var_export($_GET,1) . (The second parameter is set to 1 to return the representation of the variable instead of outputting it).
  • Click the "Rate" button to see the result in the "Result:" text area.
  • Right-click on your result and select "Copy Value" or use the copy shortcut
  • Enjoy it! (If you prefer a different output, you can use other functions, for example print_r($_GET,1) )
+12
source share

All Articles