Skip to content

Commit 54132fb

Browse files
committed
ℹ️ The PHP Info
1 parent f08e700 commit 54132fb

File tree

9 files changed

+224
-2
lines changed

9 files changed

+224
-2
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
composer.lock
2+
3+
.idea
4+
15
/vendor/
26
node_modules/
37
npm-debug.log

README.md

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,32 @@
1-
# filament-phpinfo
2-
View phpinfo from your Filament admin panel.
1+
# PHPInfo for Filament
2+
This package adds a new page to the Filament admin panel that displays the output of `phpinfo()` in a nicely formatted way.
3+
4+
## Installation
5+
```bash
6+
composer require stechstudio/filament-phpinfo
7+
```
8+
9+
In your `AdminPanelProvider` (or other `\Filament\PanelProvider`), add this package to your plugins:
10+
```php
11+
$panel
12+
->plugins([
13+
\STS\FilamentPHPInfo\FilamentPHPInfoPlugin::make(),
14+
])
15+
```
16+
17+
## Configuration
18+
The navigation group and icon are configurable.
19+
20+
Publish the `filament-phpinfo` config file with:
21+
```bash
22+
php artisan vendor:publish --tag=filament-phpinfo-config
23+
```
24+
25+
| Option | Description |
26+
|--------------------|----------------------------------------------------------------------------------------------------------------------|
27+
| `navigation-group` | The PHPInfo page's [navigation group](https://filamentphp.com/docs/3.x/panels/navigation#grouping-navigation-items). |
28+
| `navigation-icon` | The PHPInfo page's icon. See Filament's [documentation](https://filamentphp.com/docs/3.x/support/icons) for values. |
29+
30+
| Screenshot |
31+
|---|
32+
| ![PHPInfo Page](/screenshots/phpinfo.png) |

composer.json

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"name": "stechstudio/filament-phpinfo",
3+
"description": "View phpinfo from your Filament admin panel.",
4+
"type": "library",
5+
"license": "MIT",
6+
"autoload": {
7+
"psr-4": {
8+
"STS\\FilamentPHPInfo\\": "src/"
9+
}
10+
},
11+
"authors": [
12+
{
13+
"name": "Elias Szobody",
14+
"email": "elias@reproconnect.com"
15+
},
16+
{
17+
"name": "David Palmer",
18+
"email": "dp@reproconnect.com"
19+
}
20+
],
21+
"require": {
22+
"filament/filament": "^3.0",
23+
"stechstudio/phpinfo": "^0.2.0"
24+
},
25+
"extra": {
26+
"laravel": {
27+
"providers": [
28+
"STS\\FilamentPHPInfo\\FilamentPHPInfoServiceProvider"
29+
]
30+
}
31+
}
32+
}

config/filament-phpinfo.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?php
2+
3+
return [
4+
'navigation-group' => 'System Management',
5+
'navigation-icon' => 'heroicon-o-information-circle',
6+
'page-slug' => 'phpinfo',
7+
];

resources/views/phpinfo.blade.php

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<x-filament-panels::page>
2+
@foreach ($info->modules() as $module)
3+
<x-filament::section :heading="$module->name()" collapsible>
4+
@foreach ($module->groups() as $group)
5+
<x-filament-tables::table>
6+
@if ($group->headings()->isNotEmpty())
7+
<x-filament-tables::row>
8+
@foreach ($group->headings() as $heading)
9+
<x-filament-tables::header-cell>
10+
{{ $heading }}
11+
</x-filament-tables::header-cell>
12+
@endforeach
13+
</x-filament-tables::row>
14+
15+
@foreach ($group->configs() as $config)
16+
<x-filament-tables::row>
17+
<x-filament-tables::cell :style="$loop->first ? 'max-width: 24rem; min-width: 24rem; width: 24rem; vertical-align: top' : 'vertical-align: top'">
18+
<div class="filament-tables-column-wrapper px-4 py-3">
19+
{{ $config->name() }}
20+
</div>
21+
</x-filament-tables::cell>
22+
23+
<x-filament-tables::cell class="whitespace-normal" style="overflow-wrap: anywhere">
24+
<div class="filament-tables-column-wrapper px-4 py-3">
25+
{{ $config->localValue() }}
26+
</div>
27+
</x-filament-tables::cell>
28+
29+
<x-filament-tables::cell class="whitespace-normal" style="overflow-wrap: anywhere">
30+
<div class="filament-tables-column-wrapper px-4 py-3">
31+
{{ $config->masterValue() }}
32+
</div>
33+
</x-filament-tables::cell>
34+
</x-filament-tables::row>
35+
@endforeach
36+
@else
37+
@foreach ($group->configs() as $config)
38+
<x-filament-tables::row>
39+
<x-filament-tables::header-cell :style="$loop->first ? 'max-width: 24rem; min-width: 24rem; width: 24rem; vertical-align: top' : 'vertical-align: top'">
40+
{{ $config->name() }}
41+
</x-filament-tables::header-cell>
42+
43+
<x-filament-tables::cell class="whitespace-normal" style="overflow-wrap: anywhere">
44+
<div class="filament-tables-column-wrapper px-4 py-3">
45+
{{ $config->localValue() }}
46+
</div>
47+
</x-filament-tables::cell>
48+
</x-filament-tables::row>
49+
@endforeach
50+
@endif
51+
</x-filament-tables::table>
52+
@endforeach
53+
</x-filament::section>
54+
@endforeach
55+
</x-filament-panels::page>

screenshots/phpinfo.png

202 KB
Loading

src/FilamentPHPInfoPlugin.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
3+
namespace STS\FilamentPHPInfo;
4+
5+
use Filament\Contracts\Plugin;
6+
use Filament\Panel;
7+
8+
class FilamentPHPInfoPlugin implements Plugin
9+
{
10+
public static function make(): static
11+
{
12+
return app(static::class);
13+
}
14+
15+
public function getId(): string
16+
{
17+
return 'filament-phpinfo';
18+
}
19+
20+
public function register(Panel $panel): void
21+
{
22+
$panel
23+
->pages([
24+
Pages\PHPInfo::class,
25+
]);
26+
}
27+
28+
public function boot(Panel $panel): void
29+
{
30+
}
31+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
namespace STS\FilamentPHPInfo;
4+
5+
use Spatie\LaravelPackageTools\Package;
6+
use Spatie\LaravelPackageTools\PackageServiceProvider;
7+
8+
class FilamentPHPInfoServiceProvider extends PackageServiceProvider
9+
{
10+
public static string $name = 'filament-phpinfo';
11+
12+
public function configurePackage(Package $package): void
13+
{
14+
$package
15+
->name(static::$name)
16+
->hasViews()
17+
->hasConfigFile();
18+
}
19+
}

src/Pages/PHPInfo.php

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<?php
2+
3+
namespace STS\FilamentPHPInfo\Pages;
4+
5+
use Filament\Pages\Page;
6+
use STS\Phpinfo as InfoWrapper;
7+
8+
class PHPInfo extends Page
9+
{
10+
protected static ?string $title = 'PHPInfo';
11+
12+
protected static string $view = 'filament-phpinfo::phpinfo';
13+
14+
protected static ?string $navigationLabel = 'PHPInfo';
15+
16+
protected InfoWrapper\Result $info;
17+
18+
public function getViewData(): array
19+
{
20+
return [
21+
'info' => $this->getInfo(),
22+
];
23+
}
24+
25+
protected function getInfo(): InfoWrapper\Result
26+
{
27+
return $this->info ??= InfoWrapper\Info::capture();
28+
}
29+
30+
public static function getSlug(): string
31+
{
32+
return config('filament-phpinfo.page-slug', 'phpinfo');
33+
}
34+
35+
public static function getNavigationGroup(): ?string
36+
{
37+
return config('filament-phpinfo.navigation-group');
38+
}
39+
40+
public static function getNavigationIcon(): ?string
41+
{
42+
return config('filament-phpinfo.navigation-icon', 'heroicon-o-information-circle');
43+
}
44+
}

0 commit comments

Comments
 (0)