@@ -38,13 +38,14 @@ saged($i); // alias for sage();die;
38
38
sage(1); // shortcut for dumping trace
39
39
```
40
40
41
- | Function | Shorthand | |
42
- | -----------| ----------------| -------------------|
43
- | ` sage ` | ` s ` / ` d ` | Dump |
44
- | ` saged ` | ` sd ` | Dump & die |
45
- | ` ssage ` | ` ss ` | Simple dump |
46
- | ` ssaged ` | ` ssd ` | Simple dump & die |
47
- | ` sage(1) ` | ` s(1) ` /` sd(1) ` | Debug backtrace |
41
+ | Function | Shorthand | |
42
+ | -------------| -----------| --------------------------------------------------|
43
+ | ` sage ` | ` s ` | Dump (same as ` \Sage::dump() ` ) |
44
+ | ` saged ` | ` sd ` | Dump & die |
45
+ | ` ssage ` | ` ss ` | Simple dump |
46
+ | ` ssaged ` | ` ssd ` | Simple dump & die |
47
+ | ` sagetrace ` | ` s(1) ` | Debug backtrace (same as ` \Sage::trace() ` ) |
48
+ | --- | ` s(2) ` | Backtrace without the arguments - just the paths |
48
49
49
50
### Simple dump:
50
51
@@ -56,13 +57,20 @@ sage(1); // shortcut for dumping trace
56
57
57
58
### More cool stuff 🤯
58
59
59
- To output plain-text mode (no styling ** AT ALL** ) prefix with ` ~ ` . To return instead of echoing, prefix with ` @ ` :
60
+ Sage determines the ** passed variable name** and as a side effect can detect all sort of prefixes to the call. Use it
61
+ for some common on-the-fly adjustments to the dump output.
62
+
63
+ Examples:
60
64
61
65
``` php
62
- ~s($var); // outputs plain text
63
- $output = @ss(); // returns output
66
+ ~ss($var); // outputs plain text
67
+ $output = @ss($var); // returns output instead of displaying it
68
+ print sd($var); // saves output into "sage.html" in the current directory
69
+ +sage($var); // ignores depth limit for large objects
64
70
```
65
71
72
+ See [ Advanced section] ( #-advanced-tips--tricks ) below for more tricks.
73
+
66
74
### Verbose versions
67
75
68
76
If you want to use Sage as part of permanent code (e.g. part of a test helper/logger/exception reporter etc), you can
@@ -295,6 +303,7 @@ ss($GLOBALS, $_SERVER);
295
303
// show a trace
296
304
Sage::trace();
297
305
s(1); // shorthand works too!
306
+ s(2); // trace - but just the paths
298
307
Sage::dump( debug_backtrace() ); // you can even pass a custom result from debug_trace and it will be recognized
299
308
300
309
// dump and die debugging
@@ -327,15 +336,16 @@ sd('Get off my lawn!'); // no effect
327
336
328
337
For customization instructions read the section below.
329
338
* If a variable is an object, its classname can be clicked to open the class in your IDE.
330
- * There are a couple of real-time modifiers you can use:
331
- * ` ~s($var) ` this call will output in plain text format.
332
- * ` +s($var) ` will disregard depth level limits and output everything (careful, this can hang your browser on huge
333
- objects)
334
- * ` !s($var) ` will show uncollapsed rich output.
335
- * ` -s($var) ` will attempt to ` ob_clean ` the previous output - useful when Sage is obscured by already present HTML.
336
-
337
- [ Here's a little bit] ( https://stackoverflow.com/a/69890023/179104 ) on how it works.
338
-
339
+ * There are several real-time prefix modifiers you can use (combinations possible):
340
+
341
+ | Prefix | | Example |
342
+ | --------| ----------------------------------------------| --------------|
343
+ | print | Puts output into current DIR as sage.html | print sage() |
344
+ | + | Dump ignoring depth limits for large objects | + sage() |
345
+ | ~ | Simplifies sage output (rich->html->plain) | ~ sage() |
346
+ | - | Clean up any output before dumping | - sage() |
347
+ | ! | Expand all nodes (in rich view) | ! sage() |
348
+ | @ | Return output instead of displaying it | @ sage() |
339
349
340
350
* Sage also includes a naïve profiler you may find handy. It's for determining relatively which code blocks take longer
341
351
than others:
0 commit comments