PHPackages                             rolland97/filament-resource-customizer - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. rolland97/filament-resource-customizer

ActiveLibrary[Authentication &amp; Authorization](/categories/authentication)

rolland97/filament-resource-customizer
======================================

Split Filament resource tables into dedicated classes and scaffold Filament Shield permissions, including a runtime permission helper.

v2.1.1(1mo ago)4556↑36.4%[2 PRs](https://github.com/rolland97/filament-resource-customizer/pulls)MITPHPPHP ^8.3|^8.4|^8.5CI passing

Since Jan 22Pushed 1mo agoCompare

[ Source](https://github.com/rolland97/filament-resource-customizer)[ Packagist](https://packagist.org/packages/rolland97/filament-resource-customizer)[ Docs](https://github.com/rolland97/filament-resource-customizer)[ GitHub Sponsors](https://github.com/Rolland97)[ RSS](/packages/rolland97-filament-resource-customizer/feed)WikiDiscussions main Synced 1w ago

READMEChangelog (7)Dependencies (30)Versions (11)Used By (0)

Filament Resource Customizer
============================

[](#filament-resource-customizer)

[![Latest Version on Packagist](https://camo.githubusercontent.com/4388ce22b1d84bedb7d41e42b7af0e42c819dd4036ffdf00b9e4c9d9d8620287/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f726f6c6c616e6439372f66696c616d656e742d7265736f757263652d637573746f6d697a65722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/rolland97/filament-resource-customizer)[![GitHub Tests Action Status](https://camo.githubusercontent.com/1ee86b60bb399915facdeac927c3e3a03697e65bcf553fbc4cd56e9bf8f9945c/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f726f6c6c616e6439372f66696c616d656e742d7265736f757263652d637573746f6d697a65722f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/rolland97/filament-resource-customizer/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/74bada8fcb02f9792733c588b41867d8a7eb37740247174a95696eb37acbe3b5/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f726f6c6c616e6439372f66696c616d656e742d7265736f757263652d637573746f6d697a65722f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/rolland97/filament-resource-customizer/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/dcbf9d0d3d0f21156cfbae0c5a8e83ea3a4600cbcba6b96a8dba4c788fbefce6/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f726f6c6c616e6439372f66696c616d656e742d7265736f757263652d637573746f6d697a65722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/rolland97/filament-resource-customizer)

Split Filament resource tables into dedicated classes, and scaffold Filament Shield permissions — including a runtime permission helper.

What it does
------------

[](#what-it-does)

- Splits a Filament resource table into dedicated column, filter, and action classes.
- Generates a permissions class per resource (optional).
- Builds or updates Filament Shield `resources.manage` entries.
- Provides a `BaseResourcePermissions` helper whose `can()` / `permissions()` / `permissionKey()` produce Filament Shield gate strings at runtime.

Requirements
------------

[](#requirements)

- PHP 8.3, 8.4, or 8.5, and Laravel 11, 12, or 13 (this package's dependencies).
- Filament v4 or v5 — your application's dependency, not a hard composer dependency of this package.
- Filament Shield (`bezhansalleh/filament-shield`) — **optional**; required only for the permission helper (`BaseResourcePermissions::can()`/`permissions()`/`permissionKey()`) and the `filament:shield-config` command.

This package generates and rewrites Filament resource files as source code; it does not load Filament at runtime, so no `filament/*` package is a hard dependency. Generated output targets APIs common to Filament v4 and v5. Full application-level compatibility across both majors is verified manually per release (a CI matrix booting generated resources under each major is planned).

### Permission helper (`BaseResourcePermissions`)

[](#permission-helper-baseresourcepermissions)

`BaseResourcePermissions::can()`, `permissions()`, and `permissionKey()` build authorization gate strings by delegating to Filament Shield, so they require [`bezhansalleh/filament-shield`](https://github.com/bezhanSalleh/filament-shield) to be installed. Called without it, they throw a `RuntimeException`. The rest of the package (table customization, file generation) does not require Shield.

```
// Full gate string, matching what Shield registered (incl. panel prefix + case):
RequestPermissions::permissionKey('viewApprovalTrail'); // "system:ViewApprovalTrail:Request"

// Authorization check for the current user:
RequestPermissions::can('viewApprovalTrail');           // bool

// All gate strings for the class's methods():
RequestPermissions::permissions();                      // ["system:ViewApprovalTrail:Request", ...]
```

The panel prefix (`system:` above) is only added on Filament Shield versions that expose panel prefixing; on versions without it the helpers return the unprefixed key (e.g. `ViewApprovalTrail:Request`). Either way the result matches what Shield itself registered. A custom `FilamentShield::buildPermissionKeyUsing()` closure is not honored by these helpers; they use Shield's default key builder.

Installation
------------

[](#installation)

```
composer require rolland97/filament-resource-customizer
```

Install as a normal (non-dev) dependency: the package ships `BaseResourcePermissions`, which generated permission classes extend and call at runtime from your policies. Installing with `--dev` is acceptable only if you use the code-generation commands alone and never use the generated permission classes or helper at runtime.

Publish the config:

```
php artisan vendor:publish --tag="filament-resource-customizer-config"
```

Publish stubs (optional):

```
php artisan vendor:publish --tag="filament-resource-customizer-stubs"
```

Quick Start
-----------

[](#quick-start)

1. Customize a resource:

```
php artisan filament:customize-resource DepartmentResource
```

(`DepartmentResource` is just an example — replace it with your actual resource class.)

2. Or run everything at once:

```
php artisan filament:customize-resource-all DepartmentResource
```

Usage
-----

[](#usage)

Customize a resource by splitting tables/filters/actions into separate classes:

```
php artisan filament:customize-resource DepartmentResource
```

Target a specific panel:

```
php artisan filament:customize-resource DepartmentResource --panel=Admin
```

Generate a permissions class for a resource:

```
php artisan filament:make-resource-permissions DepartmentResource
```

Generate Filament Shield resources configuration:

```
php artisan filament:shield-config
```

Generate for a specific panel:

```
php artisan filament:shield-config --panel=Admin
```

Merge with existing resources:

```
php artisan filament:shield-config --merge
```

Run all steps (customize, permissions, and Shield config) in one command:

```
php artisan filament:customize-resource-all DepartmentResource
```

Run all steps for a specific panel:

```
php artisan filament:customize-resource-all DepartmentResource --panel=Admin
```

The target config must already contain a `resources.manage` array — the command updates it in place and fails with a clear message if it is absent (publish the Filament Shield config first). Everything outside `resources.manage` is left untouched.

Commands
--------

[](#commands)

CommandDescription`filament:customize-resource`Generate table, column, filter, and action classes`filament:make-resource-permissions`Generate only the permissions class`filament:shield-config`Update Filament Shield `resources.manage``filament:customize-resource-all`Run customize + permissions + Shield config### Options

[](#options)

OptionCommandsEffect`--panel=Name`allTarget a single panel (resolved from `panels.path_template`, default `app/Filament/Name/Resources`).`--force``customize-resource`, `make-resource-permissions`, `customize-resource-all`Overwrite existing generated files. A resource whose table is already customized (it delegates to generated component classes) is still refused — restore its original inline table to re-run.`--merge` / `--no-merge``shield-config`, `customize-resource-all`Merge with, or replace, existing `resources.manage` rows. Defaults to the `shield.merge` config value.`--path=``shield-config`, `customize-resource-all`Path to the Filament Shield config to update (default `config/filament-shield.php`).Configuration
-------------

[](#configuration)

Key options in `config/filament-resource-customizer.php`:

- `resources_path`: Where Filament resources live; accepts a string or array (default: `app/Filament/Resources`)
- `stubs_path`: Custom stub directory (default: `stubs/filament-resource-customizer`)
- `panels.auto_detect`: Auto-detect Filament panel resource paths under `app/Filament/*/Resources` (default: `true`)
- `permissions.enabled`: Toggle permissions generation
- `permissions.placement`: `resource`, `parent`, or `custom`
- `permissions.custom_path`: Target path if placement is `custom`
- `permissions.namespace`: Override permissions namespace
- `shield.default_methods`: Default methods when no permissions class exists
- `shield.static_resources`: Always include these resources in `manage`
- `shield.merge`: Default merge behavior for `filament:shield-config`

### Permission base class

[](#permission-base-class)

Generated permission classes extend `Rolland\FilamentResourceCustomizer\Support\BaseResourcePermissions`by default. To make them extend a shared or custom base instead (for example, a per-app base class that other permission classes inherit from), set `permissions.base_class`:

```
// config/filament-resource-customizer.php
'permissions' => [
    // ...
    'base_class' => \App\Filament\Permissions\BasePermissions::class,
],
```

The configured class must exist; generation fails with a clear error otherwise. The generated file imports it automatically (unless it lives in the generated class's own namespace).

### Generated permission methods

[](#generated-permission-methods)

Generated permission classes are populated from `shield.default_methods`: each method becomes a `SCREAMING_SNAKE` constant, and `methods()` returns those constants.

```
class UserPermissions extends BaseResourcePermissions
{
    public const VIEW_ANY = 'viewAny';
    // ... view, create, update, delete

    public static function methods(): array
    {
        return [self::VIEW_ANY /* , ... */];
    }
}
```

Add your resource-specific permissions (e.g. `viewApprovalTrail`) as extra constants and append them to `methods()`. Set `shield.default_methods` to `[]` to generate an empty `methods()`.

### Filament Shield integration

[](#filament-shield-integration)

If you use Filament Shield, the `filament:shield-config` command will update `resources.manage`. By default it replaces entries unless you:

- pass `--merge`, or
- set `shield.merge` to `true` in the config.

**Keeping hand-maintained config across runs.** `filament:shield-config` only rewrites the `resources.manage` array — every other section of `config/filament-shield.php` (for example `policies.single_parameter_methods`) is left untouched. To keep extra entries inside `manage`:

- run with `--merge` (or set `shield.merge` to `true`) so existing `manage` rows are preserved alongside the generated ones;
- declare rows that should always be present in `shield.static_resources`(config: `filament-resource-customizer.shield.static_resources`) — these are injected on every run and survive even without `--merge`.

Note: comments written *inside* the `manage` array are not preserved when it is regenerated; comments elsewhere in the file are kept.

### Multi-panel setups

[](#multi-panel-setups)

You can use any combination of these:

- `--panel=Admin` to target a single panel for a command.
- `resources_path` as an array, e.g. `['app/Filament/Resources', 'app/Filament/Admin/Resources']`.
- `panels.auto_detect=true` to auto-add `app/Filament/*/Resources` alongside the configured paths.

Example Structure
-----------------

[](#example-structure)

Running the customize command for a resource will generate classes like these:

```
app/Filament/Resources/Department/Departments/
├── DepartmentResource.php
├── DepartmentPermissions.php
└── Tables/
    ├── DepartmentsTable.php
    ├── DepartmentsColumn.php
    ├── DepartmentsFilter.php
    ├── DepartmentsRecordAction.php
    └── DepartmentsToolbarAction.php

```

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information.

Upgrading
---------

[](#upgrading)

### To the shield-aware permission helper

[](#to-the-shield-aware-permission-helper)

`BaseResourcePermissions::permissions()` now returns full Shield gate strings (e.g. `system:ViewApprovalTrail:Request`) instead of the previous `method:Resource` form, and `can()`now returns correct results in panel-prefixed apps. If you hardcoded gate strings in your policies, you can replace them with `YourPermissions::can('method')`. These methods now require `bezhansalleh/filament-shield`.

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

49

—

FairBetter than 94% of packages

Maintenance92

Actively maintained with recent releases

Popularity23

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 93.5% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~28 days

Recently: every ~40 days

Total

7

Last Release

42d ago

Major Versions

v1.2.0 → v2.0.02026-07-07

PHP version history (2 changes)v1.0.0PHP ^8.3|^8.4

v1.2.0PHP ^8.3|^8.4|^8.5

### Community

Maintainers

![](https://www.gravatar.com/avatar/072504bf43e99fdc8f189025ab94c9e3881159c13e8302392b34ded98611fd26?d=identicon)[rolland97](/maintainers/rolland97)

---

Top Contributors

[![rolland97](https://avatars.githubusercontent.com/u/87228813?v=4)](https://github.com/rolland97 "rolland97 (58 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (3 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (1 commits)")

---

Tags

laravelgeneratorpermissionsfilamentRolland97filament-resource-customizer

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/rolland97-filament-resource-customizer/health.svg)

```
[![Health](https://phpackages.com/badges/rolland97-filament-resource-customizer/health.svg)](https://phpackages.com/packages/rolland97-filament-resource-customizer)
```

###  Alternatives

[spatie/laravel-permission

Permission handling for Laravel 12 and up

13.0k107.5M1.6k](/packages/spatie-laravel-permission)[rawilk/profile-filament-plugin

Profile &amp; MFA starter kit for filament.

3915.5k](/packages/rawilk-profile-filament-plugin)[bezhansalleh/filament-shield

Filament support for `spatie/laravel-permission`.

2.8k4.3M161](/packages/bezhansalleh-filament-shield)[codewithdennis/filament-select-tree

The multi-level select field enables you to make single selections from a predefined list of options that are organized into multiple levels or depths.

329575.9k35](/packages/codewithdennis-filament-select-tree)[spatie/laravel-passkeys

Use passkeys in your Laravel app

4721.0M48](/packages/spatie-laravel-passkeys)[harris21/laravel-fuse

Circuit breaker for Laravel queue jobs. Protect your workers from cascading failures.

46273.9k](/packages/harris21-laravel-fuse)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
