Skip to content

Commit

Permalink
ℹ️ The PHP Info
Browse files Browse the repository at this point in the history
  • Loading branch information
dp88 committed Oct 23, 2023
1 parent f08e700 commit 54132fb
Show file tree
Hide file tree
Showing 9 changed files with 224 additions and 2 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
composer.lock

.idea

/vendor/
node_modules/
npm-debug.log
Expand Down
34 changes: 32 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,32 @@
# filament-phpinfo
View phpinfo from your Filament admin panel.
# PHPInfo for Filament
This package adds a new page to the Filament admin panel that displays the output of `phpinfo()` in a nicely formatted way.

## Installation
```bash
composer require stechstudio/filament-phpinfo
```

In your `AdminPanelProvider` (or other `\Filament\PanelProvider`), add this package to your plugins:
```php
$panel
->plugins([
\STS\FilamentPHPInfo\FilamentPHPInfoPlugin::make(),
])
```

## Configuration
The navigation group and icon are configurable.

Publish the `filament-phpinfo` config file with:
```bash
php artisan vendor:publish --tag=filament-phpinfo-config
```

| Option | Description |
|--------------------|----------------------------------------------------------------------------------------------------------------------|
| `navigation-group` | The PHPInfo page's [navigation group](https://filamentphp.com/docs/3.x/panels/navigation#grouping-navigation-items). |
| `navigation-icon` | The PHPInfo page's icon. See Filament's [documentation](https://filamentphp.com/docs/3.x/support/icons) for values. |

| Screenshot |
|---|
| ![PHPInfo Page](/screenshots/phpinfo.png) |
32 changes: 32 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"name": "stechstudio/filament-phpinfo",
"description": "View phpinfo from your Filament admin panel.",
"type": "library",
"license": "MIT",
"autoload": {
"psr-4": {
"STS\\FilamentPHPInfo\\": "src/"
}
},
"authors": [
{
"name": "Elias Szobody",
"email": "[email protected]"
},
{
"name": "David Palmer",
"email": "[email protected]"
}
],
"require": {
"filament/filament": "^3.0",
"stechstudio/phpinfo": "^0.2.0"
},
"extra": {
"laravel": {
"providers": [
"STS\\FilamentPHPInfo\\FilamentPHPInfoServiceProvider"
]
}
}
}
7 changes: 7 additions & 0 deletions config/filament-phpinfo.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

return [
'navigation-group' => 'System Management',
'navigation-icon' => 'heroicon-o-information-circle',
'page-slug' => 'phpinfo',
];
55 changes: 55 additions & 0 deletions resources/views/phpinfo.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<x-filament-panels::page>
@foreach ($info->modules() as $module)
<x-filament::section :heading="$module->name()" collapsible>
@foreach ($module->groups() as $group)
<x-filament-tables::table>
@if ($group->headings()->isNotEmpty())
<x-filament-tables::row>
@foreach ($group->headings() as $heading)
<x-filament-tables::header-cell>
{{ $heading }}
</x-filament-tables::header-cell>
@endforeach
</x-filament-tables::row>

@foreach ($group->configs() as $config)
<x-filament-tables::row>
<x-filament-tables::cell :style="$loop->first ? 'max-width: 24rem; min-width: 24rem; width: 24rem; vertical-align: top' : 'vertical-align: top'">
<div class="filament-tables-column-wrapper px-4 py-3">
{{ $config->name() }}
</div>
</x-filament-tables::cell>

<x-filament-tables::cell class="whitespace-normal" style="overflow-wrap: anywhere">
<div class="filament-tables-column-wrapper px-4 py-3">
{{ $config->localValue() }}
</div>
</x-filament-tables::cell>

<x-filament-tables::cell class="whitespace-normal" style="overflow-wrap: anywhere">
<div class="filament-tables-column-wrapper px-4 py-3">
{{ $config->masterValue() }}
</div>
</x-filament-tables::cell>
</x-filament-tables::row>
@endforeach
@else
@foreach ($group->configs() as $config)
<x-filament-tables::row>
<x-filament-tables::header-cell :style="$loop->first ? 'max-width: 24rem; min-width: 24rem; width: 24rem; vertical-align: top' : 'vertical-align: top'">
{{ $config->name() }}
</x-filament-tables::header-cell>

<x-filament-tables::cell class="whitespace-normal" style="overflow-wrap: anywhere">
<div class="filament-tables-column-wrapper px-4 py-3">
{{ $config->localValue() }}
</div>
</x-filament-tables::cell>
</x-filament-tables::row>
@endforeach
@endif
</x-filament-tables::table>
@endforeach
</x-filament::section>
@endforeach
</x-filament-panels::page>
Binary file added screenshots/phpinfo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
31 changes: 31 additions & 0 deletions src/FilamentPHPInfoPlugin.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

namespace STS\FilamentPHPInfo;

use Filament\Contracts\Plugin;
use Filament\Panel;

class FilamentPHPInfoPlugin implements Plugin
{
public static function make(): static
{
return app(static::class);
}

public function getId(): string
{
return 'filament-phpinfo';
}

public function register(Panel $panel): void
{
$panel
->pages([
Pages\PHPInfo::class,
]);
}

public function boot(Panel $panel): void
{
}
}
19 changes: 19 additions & 0 deletions src/FilamentPHPInfoServiceProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

namespace STS\FilamentPHPInfo;

use Spatie\LaravelPackageTools\Package;
use Spatie\LaravelPackageTools\PackageServiceProvider;

class FilamentPHPInfoServiceProvider extends PackageServiceProvider
{
public static string $name = 'filament-phpinfo';

public function configurePackage(Package $package): void
{
$package
->name(static::$name)
->hasViews()
->hasConfigFile();
}
}
44 changes: 44 additions & 0 deletions src/Pages/PHPInfo.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php

namespace STS\FilamentPHPInfo\Pages;

use Filament\Pages\Page;
use STS\Phpinfo as InfoWrapper;

class PHPInfo extends Page
{
protected static ?string $title = 'PHPInfo';

protected static string $view = 'filament-phpinfo::phpinfo';

protected static ?string $navigationLabel = 'PHPInfo';

protected InfoWrapper\Result $info;

public function getViewData(): array
{
return [
'info' => $this->getInfo(),
];
}

protected function getInfo(): InfoWrapper\Result
{
return $this->info ??= InfoWrapper\Info::capture();
}

public static function getSlug(): string
{
return config('filament-phpinfo.page-slug', 'phpinfo');
}

public static function getNavigationGroup(): ?string
{
return config('filament-phpinfo.navigation-group');
}

public static function getNavigationIcon(): ?string
{
return config('filament-phpinfo.navigation-icon', 'heroicon-o-information-circle');
}
}

0 comments on commit 54132fb

Please sign in to comment.