Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support v3 #37

Merged
merged 4 commits into from
Aug 4, 2023
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
name: Check & fix styling
name: Fix PHP code style issues

on: [push]
on:
push:
paths:
- '**.php'

permissions:
contents: write

jobs:
php-cs-fixer:
php-code-styling:
runs-on: ubuntu-latest

steps:
Expand All @@ -12,12 +18,10 @@ jobs:
with:
ref: ${{ github.head_ref }}

- name: Run PHP CS Fixer
uses: docker://oskarstark/php-cs-fixer-ga
with:
args: --config=.php_cs.dist.php --allow-risky=yes
- name: Fix PHP code style issues
uses: aglipanci/[email protected]

- name: Commit changes
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: Fix styling
commit_message: chore: fix styling
2 changes: 1 addition & 1 deletion .github/workflows/phpstan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.0'
php-version: '8.1'
coverage: none

- name: Install composer dependencies
Expand Down
13 changes: 6 additions & 7 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,13 @@ jobs:
fail-fast: true
matrix:
os: [ubuntu-latest, windows-latest]
php: ['8.0', 8.1]
laravel: [8.*, 9.*]
stability: [prefer-stable]
php: [8.2, 8.1]
laravel: [10.*]
stability: [prefer-lowest, prefer-stable]
include:
- laravel: 8.*
testbench: ^6.23
- laravel: 9.*
testbench: ^7.0
- laravel: 10.*
testbench: 8.*
carbon: ^2.63

name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }}

Expand Down
40 changes: 0 additions & 40 deletions .php_cs.dist.php

This file was deleted.

109 changes: 86 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,32 +29,23 @@ php artisan vendor:publish --tag="health-migrations"
php artisan migrate
```

You can publish the config file with:
Publish the package's assets:

```bash
php artisan vendor:publish --tag="filament-spatie-health-config"
php artisan filament:assets
```

This is the contents of the published config file:
## Configuring the panel with a plugin class

The users of your plugin can add it to a panel by instantiating the plugin class and passing it to the plugin() method of the [configuration](https://filamentphp.com/docs/3.x/panels/configuration):

```php
return [

/*
|--------------------------------------------------------------------------
| Pages
|--------------------------------------------------------------------------
|
| This is the configuration for the general appearance of the page
| in admin panel.
|
*/

'pages' => [
'health' => \ShuvroRoy\FilamentSpatieLaravelHealth\Pages\HealthCheckResults::class
],

];
public function panel(Panel $panel): Panel
{
return $panel
// ...
->plugin(new HealthCheckResults());
}
```

## Usage
Expand All @@ -63,7 +54,29 @@ This package will automatically register the `HealthCheckResults`. You'll be abl

## Defining Resources to health check

Register Health::checks on app/Providers/AppServiceProvider.php -> `boot` method
You first need to register the plugin with Filament. This can be done inside of your `PanelProvider`, e.g. `AdminPanelProvider`.

```php
<?php

namespace App\Providers\Filament;

use Filament\Panel;
use Filament\PanelProvider;
use ShuvroRoy\FilamentSpatieLaravelHealth\Pages\HealthCheckResults;

class AdminPanelProvider extends PanelProvider
{
public function panel(Panel $panel): Panel
{
return $panel
// ...
->plugin(HealthCheckResults::make());
}
}
```

Then register Health::checks on app/Providers/AppServiceProvider.php -> `boot` method

```php
<?php
Expand All @@ -77,7 +90,7 @@ use Spatie\Health\Checks\Checks\EnvironmentCheck;

class AppServiceProvider extends ServiceProvider
{
public function boot()
public function boot(): void
{
Health::checks([
OptimizedAppCheck::new(),
Expand All @@ -88,7 +101,57 @@ class AppServiceProvider extends ServiceProvider
}
```

Read the full documentation on [Spatie Laravel Health](https://spatie.be/docs/laravel-health/v1/available-checks/overview)
Read the full documentation on [Spatie Laravel Health](https://spatie.be/docs/laravel-health/v1/available-checks/overview)

If you want to override the default `HealthCheckResults` page icon, heading then you can extend the page class and override the `navigationIcon` property and `getHeading` method and so on.

```php
<?php

namespace App\Filament\Pages;

use ShuvroRoy\FilamentSpatieLaravelHealth\Pages\HealthCheckResults as BaseHealthCheckResults;

class HealthCheckResults extends BaseHealthCheckResults
{
protected static ?string $navigationIcon = 'heroicon-o-cpu-chip';

public function getHeading(): string | Htmlable
{
return 'Health Check Results'
}

public static function getNavigationGroup(): ?string
{
return 'Core';
}
}
```
Then register the extended page class on `AdminPanelProvider` class.

```php
<?php

namespace App\Providers\Filament;

use Filament\Panel;
use Filament\PanelProvider;
use App\Filament\Pages\HealthCheckResults;

class AdminPanelProvider extends PanelProvider
{
public function panel(Panel $panel): Panel
{
return $panel
// ...
->plugin(
HealthCheckResults::make()
->usingPage(HealthCheckResults::class)
);
}
}
```


## Testing

Expand Down
82 changes: 82 additions & 0 deletions UPGRADE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# Upgrade Guide

## Upgrading from v1.x to v2.0

Starting with version v1.0, this package now only supports Filament v3.x.

Follow these steps to update the package for Filament v3.x.

1. Update the package version in your `composer.json`.
2. Run `composer update`.
3. Register the plugin inside of your project's `PanelProvider`, e.g. `AdminPanelProvider`.

```php
<?php

namespace App\Providers\Filament;

use Filament\Panel;
use Filament\PanelProvider;
use ShuvroRoy\FilamentSpatieLaravelHealth\Pages\HealthCheckResults;

class AdminPanelProvider extends PanelProvider
{
public function panel(Panel $panel): Panel
{
return $panel
// ...
->plugin(HealthCheckResults::make());
}
}
```

4. Publish the plugin assets.

```sh
php artisan filament:assets
```

5. Open your panel and check that the resource has been registered and existing navigation menus are showing.

If you have registered custom navigation item types, the `addItemType()` method no longer exists.

Instead, register the item types on the `FilamentNavigation` plugin object directly.

```php
return $panel
->plugin(
FilamentNavigation::make()
->itemType('post', [
Select::make('post_id')
->//...
])
)
// ...
```

If you previously used the configuration file to change the `health` value, those no longer exist and need to be updated to method calls on the plugin object.

```php
<?php

namespace App\Providers\Filament;

use Filament\Panel;
use Filament\PanelProvider;
use App\Filament\Pages\HealthCheckResults;

class AdminPanelProvider extends PanelProvider
{
public function panel(Panel $panel): Panel
{
return $panel
// ...
->plugin(
HealthCheckResults::make()
->usingPage(HealthCheckResults::class)
);
}
}
```

If you have any issues with the upgrade, please open an issue and provide details. Reproduction repositories are much appreciated.
25 changes: 13 additions & 12 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,22 @@
}
],
"require": {
"php": "^8.0",
"filament/filament": "^2.0",
"spatie/laravel-health": "^1.7|^1.8",
"spatie/laravel-package-tools": "^1.11"
"php": "^8.1",
"filament/filament": "^3.0",
"spatie/laravel-health": "^1.23",
"spatie/laravel-package-tools": "^1.15"
},
"require-dev": {
"nunomaduro/collision": "^5.10|^6.0",
"nunomaduro/larastan": "^1.0|^2.0",
"orchestra/testbench": "^6.22|^7.0",
"pestphp/pest": "^1.21",
"pestphp/pest-plugin-laravel": "^1.1",
"laravel/pint": "^1.0",
"nunomaduro/collision": "^7.9",
"nunomaduro/larastan": "^2.0.1",
"orchestra/testbench": "^8.0",
"pestphp/pest": "^2.0",
"pestphp/pest-plugin-arch": "^2.0",
"pestphp/pest-plugin-laravel": "^2.0",
"phpstan/extension-installer": "^1.1",
"phpstan/phpstan-deprecation-rules": "^1.0",
"phpstan/phpstan-phpunit": "^1.0",
"phpunit/phpunit": "^9.5"
"phpstan/phpstan-phpunit": "^1.0"
},
"autoload": {
"psr-4": {
Expand All @@ -45,7 +46,7 @@
"scripts": {
"analyse": "vendor/bin/phpstan analyse",
"test": "vendor/bin/pest",
"test-coverage": "vendor/bin/pest coverage"
"format": "vendor/bin/pint"
},
"config": {
"sort-packages": true,
Expand Down
19 changes: 0 additions & 19 deletions config/filament-spatie-laravel-health.php

This file was deleted.

1 change: 0 additions & 1 deletion dist/health.css

This file was deleted.

Loading