Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,32 @@ $phpInfo = new \Spaze\PhpInfo\PhpInfo();
$html = $phpInfo->getHtml();
```

## `getHtml()`
## `getHtml(int $flags = INFO_ALL): string`
The `getHtml()` method returns the `phpinfo()` output, without the HTML `head` and `body` elements, wrapped in `<div id="phpinfo">` & `</div>`.

All inline CSS will be "externalized" to CSS classes, you can load `assets/info.css` to get the colors back.
All inline CSS will be "externalized" to CSS classes, you can load `src/assets/info.css` to get the colors back (or `vendor/spaze/phpinfo/src/assets/info.css` when installed via Composer).

An example usage with Nette Framework (can be used with other frameworks or standalone, too):
```php
$this->template->phpinfo = Html::el()->setHtml($this->phpInfo->getHtml());
```

The output may be customized by passing one or more of the constants [specified in the PHP manual](https://www.php.net/function.phpinfo#refsect1-function.phpinfo-parameters) in the optional `$flags` parameter.

Please note that this will also remove the HTML `head` element which contains `meta name="ROBOTS"` tag preventing search engines and other bots indexing the `phpinfo()` output.
You have to add it back somehow, for example by rendering the `getHtml()` output in your own layout which includes the `head` element with the `meta name="ROBOTS"` tag.
In general, `phpinfo()` output should be accessible only for authenticated users.

## `getFullPageHtml()`
## `getFullPageHtml(int $flags = INFO_ALL): string`
Sometimes, you may want to display the classic `phpinfo()` output, with the original HTML `head` and `body` elements, `meta name="ROBOTS"` tag, inline styles etc.,
but still with the sensitive info sanitized (see below). In that case, you may use `getFullPageHtml()`:
```php
$phpInfo = new \Spaze\PhpInfo\PhpInfo();
echo $phpInfo->getFullPageHtml();
```

The output of this method may also be customized by passing one or more of the constants [specified in the PHP manual](https://www.php.net/function.phpinfo#refsect1-function.phpinfo-parameters) in the optional `$flags` parameter.
Comment thread
spaze marked this conversation as resolved.

## Sanitization
By default, session id will be automatically determined and replaced by `[***]` in the output.
This is to prevent some session hijacking attacks that would read the session id from the cookie value reflected in the `phpinfo()` output
Expand Down