Skip to content

Commit 5a95c5f

Browse files
committed
Lots of stuff.
* cli view and simple html share same-ish colors * cli view shows color indicators of current level * plain view readability enhancements * datetime of dump in rich view * phpstorm-plugin renamed to phpstorm-remote, doesn't work either way, thanks, jetbrains * improvements to enum and alternatives displays * switched functionalities of ! and + modifiers as it makes more intuitive sense * improvements to classname, color, splfileinfo variables * finally fixed footer [+] keyboard navigation * TAB button now jumps out of sage keyboard navigation * removed more useless tests, sigh this needs work * more obvious indication that direct, non-variable parameters were passed * streamlined output simplification, just makes sense now Known issues: since PHP8.2 the debug_backtrace output changed what line is indicated, effectively breaking current variable name detection for multiline sage calls, not too difficult to fix.
1 parent 4e41355 commit 5a95c5f

15 files changed

+299
-228
lines changed

README.md

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ require 'sage.phar';
2727
sage('Hello, 🌎!');
2828
```
2929

30-
3130
## Usage
3231

3332
```php
@@ -45,7 +44,7 @@ sage(1); // shortcut for dumping trace
4544
| `ssage` | `ss` | Simple dump |
4645
| `ssaged` | `ssd` | Simple dump & die |
4746
| `sagetrace` | `s(1)` | Debug backtrace (same as `\Sage::trace()`) |
48-
| --- | `s(2)` | Backtrace without the arguments - just the paths |
47+
| --- | `s(2)` | Backtrace without the arguments - just the paths |
4948

5049
### Simple dump:
5150

@@ -57,16 +56,17 @@ sage(1); // shortcut for dumping trace
5756

5857
### More cool stuff 🤯
5958

60-
Sage determines the **passed variable name** and as a side effect can detect all sort of prefixes to the call. Use it
59+
Sage determines the **passed variable name** and as a side effect can detect all sort of prefixes to the call. Use it
6160
for some common on-the-fly adjustments to the dump output.
6261

6362
Examples:
6463

6564
```php
6665
~ss($var); // outputs plain text
6766
$output = @ss($var); // returns output instead of displaying it
67+
! sage($var); // ignores depth limit for large objects
6868
print sd($var); // saves output into "sage.html" in the current directory
69-
+sage($var); // ignores depth limit for large objects
69+
print ! sd($var); // saves output into "sage.html" while also ignoring the output depth limit!
7070
```
7171

7272
See [Advanced section](#-advanced-tips--tricks) below for more tricks.
@@ -132,9 +132,8 @@ Sage::$theme = Sage::THEME_LIGHT;
132132

133133
Add this entry to the `autoload.files` configuration key in `composer.json`:
134134

135-
```json
135+
```js
136136
"autoload": {
137-
/* ... */
138137
"files": [
139138
"config/sage.php" /* <--------------- this line */
140139
]
@@ -182,7 +181,7 @@ Make visible source file paths clickable to open your editor. Available options
182181
* `'emacs'`
183182
* `'macvim'`
184183
* `'phpstorm'`
185-
* `'phpstorm-plugin'` - default,
184+
* `'phpstorm-remote'` - default,
186185
requires [IDE Remote Control](https://plugins.jetbrains.com/plugin/19991-ide-remote-control) plugin.
187186
* `'idea'`
188187
* `'vscode'`
@@ -296,6 +295,9 @@ Sage::dump($GLOBALS, $_SERVER);
296295

297296
// ss() will display a more basic, javascript-free display (but with colors)
298297
ss($GLOBALS, $_SERVER);
298+
// to recap: s() or sage() - dumps. Add "d" to die afterwards: sd(), saged()
299+
// preppend "s" to simplify output: ss(), ssage().
300+
// works in combination, too: ssd() and ssagedd() will dump in "simple mode" and die!
299301

300302
// prepending a tilde will make the output *even more basic* (rich->basic and basic->plain text)
301303
~d($GLOBALS, $_SERVER); // more on modifiers below
@@ -316,7 +318,8 @@ Sage::enabled(false);
316318
sd('Get off my lawn!'); // no effect
317319
```
318320

319-
* Sage supports keyboard shortcuts! Just press <kbd>d</kbd> when viewing output and the rest is self-explanatory (p.s.
321+
* Sage supports keyboard shortcuts! Just press <kbd>d</kbd> when viewing output and the rest is self-explanatory, try it
322+
out! (p.s.
320323
vim-style `hjkl` works as well);
321324
* Call `Sage::enabled(Sage::MODE_PLAIN);` to switch to a simpler, js-free output.
322325
* Call `Sage::enabled(Sage::MODE_TEXT_ONLY);` for pure-plain text output which you can save or pass around by first
@@ -341,17 +344,17 @@ sd('Get off my lawn!'); // no effect
341344
| Prefix | | Example |
342345
|--------|----------------------------------------------|--------------|
343346
| print | Puts output into current DIR as sage.html | print sage() |
344-
| + | Dump ignoring depth limits for large objects | + sage() |
347+
| ! | Dump ignoring depth limits for large objects | ! sage() |
345348
| ~ | Simplifies sage output (rich->html->plain) | ~ sage() |
346349
| - | Clean up any output before dumping | - sage() |
347-
| ! | Expand all nodes (in rich view) | ! sage() |
350+
| + | Expand all nodes (in rich view) | + sage() |
348351
| @ | Return output instead of displaying it | @ sage() |
349352

350353
* Sage also includes a naïve profiler you may find handy. It's for determining relatively which code blocks take longer
351354
than others:
352355

353356
```php
354-
Sage::dump( microtime() ); // just pass microtime()
357+
Sage::dump( microtime() ); // just pass microtime() - also works if you pass NOTHING: s();
355358
sleep( 1 );
356359
Sage::dump( microtime(), 'after sleep(1)' );
357360
sleep( 2 );
@@ -395,10 +398,10 @@ sd( microtime(), 'final call, after sleep(2)' );
395398
### 💬 Why does Sage look so much like Kint? A.K.A. Why does this have so few stars?
396399

397400
Because it <b>is</b> Kint, and I am its author, however the project was [**forcibly taken over
398-
**](https://github.com/kint-php/kint/commit/1ea81f3add81b586756515673f8364f60feb86a3) from me by a malicious
401+
**](https://github.com/kint-php/kint/commit/1ea81f3add81b586756515673f8364f60feb86a3) by a malicious
399402
contributor!
400403

401-
Instead of fighting DMCA windmills, I chose to fork and rename the last **good** version and continue under a new name!
404+
Instead of fighting DMCA windmills, I chose to fork and rename the last good version and continue under a new name!
402405

403406
You can use Sage as a drop-in replacement for Kint. Simple.
404407

0 commit comments

Comments
 (0)