Download the PHP package agroezinger/filament-shield-enhanced without Composer

On this page you can find all versions of the php package agroezinger/filament-shield-enhanced. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package filament-shield-enhanced

Filament Shield Enhanced

Plumb score Plumb security score Plumb maintenance score Plumb ecosystem score Scanned by Plumb

[!WARNING] Testing Phase: Versions 0.*.* are currently in the testing phase. At present, there are no known bugs.

A standalone addon for bezhansalleh/filament-shield that adds fine-grained page, resource and component permissions and a structured Role Resource UI — without forking or replacing the original package.

Why this exists.
The features were proposed upstream in bezhanSalleh/filament-shield#698. The author has not had time to review the PR. This addon ships the same functionality as a composable layer on top of the official package.


Table of Contents


Features

Feature Description
Multi-action page permissions Declare several permissions per page via getShieldPagePermissions().
Multi-action resource permissions Declare custom permissions per resource via getShieldResourcePermissions() — beyond the standard CRUD policy methods.
Multi-action component permissions Declare permissions on any Livewire component (not registered with a panel) via getShieldComponentPermissions().
canShield('action') Fluent, type-safe permission check — instance method on Pages and Components, static method on Resources.
getShieldPermissions() Returns a pre-resolved action → bool map for injection into child Livewire components.
HasInjectedShieldPermissions Trait for child Livewire components that receive the map from a parent page or component.
EnhancedPagePermissionsForm Form builder helper for the published RoleResource — one Section per Page, combining filament-shield's own standard permission with any fine-grained actions from getShieldPagePermissions() in the same checkbox list.
EnhancedResourcePermissionsForm Form builder helper for the published RoleResource — one Section per Resource, combining the standard CRUD permissions with any fine-grained actions from getShieldResourcePermissions() in the same checkbox list.
EnhancedComponentPermissionsForm Form builder helper for the published RoleResource — renders each enhanced component as a separate Section with individual checkboxes.
getShieldPermissionDescriptions() Optional hook on Resources/Pages (with or without fine-grained actions) to attach a help text under any individual permission checkbox — standard CRUD included. Use it where the checkbox's real-world effect deviates from what its label implies.
NavigationGroupResolver Resolves a Resource's/Page's navigation group to a display string, and the panel's own ->navigationGroups() order — the building block behind grouping the RoleResource UI the same way the sidebar is grouped.
discoverResources() / discoverPages() Public on EnhancedResourcePermissionsForm / EnhancedPagePermissionsForm — return every Resource/Page's merged permission options, descriptions, navigation group and sort as plain data, for building a custom RoleResource layout (see §8c).
Three-part page key convention {Prefix}{sep}{Action}{sep}{Subject} (e.g. Page:EditSettings:SettingsPage) — fully respects filament-shield's separator and case config.
Three-part component key convention {Prefix}{sep}{Action}{sep}{Subject} (e.g. Component:Delete:CommentComponent) — same shape as pages, configurable prefix.
Two-part resource key convention {Action}{sep}{ModelBasename} (e.g. ViewContactInfo:Member) — matches Shield's own resource permission format, no extra prefix.
Zero conflict Does not replace any original class. Falls back gracefully on entities that do not declare the method.

Requirements

Dependency Version
PHP ^8.2
Laravel ^11.0 | ^12.0 | ^13.0
Filament ^4.0 | ^5.0
bezhansalleh/filament-shield ^4.0

Installation

Publish the config (optional):


Usage — Pages

1 — Declare fine-grained permissions on a Page

Replace (or complement) the original HasPageShield with the enhanced version:

Then run the enhanced generator to create the permissions in the database:

Use --panel=<id> to limit the scan to a single panel.

This will create three permissions for the page above:


2 — Check permissions in PHP (Pages)


3 — Inject permissions into child Livewire components

Parent page Blade:

Child Livewire component:


Usage — Resources

4 — Declare fine-grained permissions on a Resource

Add HasResourceShield to any Filament Resource and declare custom actions via getShieldResourcePermissions():

Then create the permissions in the database:

This will create (for the example above):

The key format (Action:ModelBasename) is identical to Shield's own resource permission format so everything looks consistent.


5 — Check resource permissions in PHP

canShield() is a static method on Resources (unlike Pages, where it is an instance method):

Super-admin bypass is applied automatically — identical behaviour to the page trait.


Attaching a deviation hint to any permission checkbox

getShieldPermissionDescriptions() is a separate, optional hook — it works even on standard CRUD permissions that were never declared via getShieldResourcePermissions()/getShieldPagePermissions(). Use it where the checkbox's real-world effect doesn't match what its label implies (an unimplemented scope, a permission that also grants an unrelated side effect, …):

The description renders directly under the matching checkbox in the RoleResource UI, regardless of whether that checkbox came from Shield's own CRUD policy methods or from getShieldResourcePermissions()/getShieldPagePermissions().


Usage — Components

Components are arbitrary Livewire components that aren't registered with any Filament panel (e.g. a shared widget dropped into several pages via @livewire(...)). Shield's own Page/Resource/Widget discovery never sees them, so they get their own trait, key format and generator command — everything else (checks, injection, RoleResource UI) works the same way as Pages.

6 — Declare fine-grained permissions on a component

By default, components are discovered by scanning app/Livewire for classes using HasComponentShield (configurable — see Configuration). Then create the permissions in the database:

This will create (for the example above):

7 — Check permissions in PHP (Components)

getShieldPermissions() and HasInjectedShieldPermissions work exactly as documented for Pages (see step 3) — a component can inject its resolved permission map into a child component the same way a page does.


8 — Structured UI in the published RoleResource

After publishing the RoleResource with php artisan shield:publish --panel=<id> two files need small changes.

8a — RoleResource: replace the standard Resources/Pages tabs

EnhancedResourcePermissionsForm::make() / EnhancedPagePermissionsForm::make() fully replace Shield's own "Resources"/"Pages" tabs — each Resource/Page gets one Section combining the standard CRUD permissions with any fine-grained actions in the same checkbox list, instead of splitting them across a standard tab and a separate "(Fine-grained)" tab. No getPageOptions() override is needed any more — there is nothing left to de-duplicate.

Each make() output is already grouped into sub-tabs by navigation group internally, always in the panel's own ->navigationGroups() order — Resources/Pages without a $navigationGroup fall into a "Sonstige" bucket. Widgets and Custom Permissions have no navigation group at all, so they stay on Shield's own standard tabs.

8b — EditRole: add the pre-fill trait

Open the published EditRole.php and add use HasEnhancedRoleForm. This pre-fills page-, resource- and component-permission checkboxes when the form opens.

The mutateFormDataBeforeSave() / afterSave() logic from Shield's own EditRole handles saving — no additional overrides needed.

8c — Optional: group everything by navigation, in one unified tab bar

A plain make() (§8a) puts every Resource/Page in the panel into one flat list of Sections — fine for a handful of them, but once a panel has two or three dozen, a role editor scrolling through an undifferentiated wall of checkboxes stops being able to find anything. Grouping by navigation — the same grouping the sidebar already uses, so nothing new to learn — exists as an option rather than the default specifically to keep that overview intact for larger panels, without forcing it on apps where a flat list is already perfectly readable.

make() (§8a) already groups Resources and Pages by navigation group internally, as two separate top-level tabs ("Resources", "Pages"). If you'd rather have navigation group be the outermost grouping — one tab bar for "Members"/"Team"/"Settings"/…, each containing a "Resources"/"Pages" sub-split underneath, matching the sidebar exactly — combine the public discoverResources() / discoverPages() / buildSection() methods yourself. ui.group_by_navigation (see Configuration) toggles the two:

group_by_navigation: true — top level clusters by navigation group, matching the sidebar exactly (red); a second tab row underneath separates Resources from Pages within each group (green):

group_by_navigation: false — no navigation-group tabs at all; the Resources/Pages/Widgets sub-tabs sit directly at the top level instead, each showing every entry of that type across the whole panel in one flat list (red):

This is exactly the recipe the screenshots above were taken from:

This full pattern — including the "Sonstige" catch-all tab for ungrouped Resources/Pages plus Widgets/Custom Permissions, and the ui.group_by_navigation on/off switch — is what ClubManager's own RoleResource implements; treat the sketch above as a starting point, not a drop-in.


Configuration


Localization

Section titles come from each Resource's/Page's own getModelLabel() / navigation label — if your app already localizes those, they localize here too. Everything this addon itself adds — permission labels/descriptions passed to getShieldResourcePermissions() / getShieldPagePermissions() / getShieldPermissionDescriptions(), and the ui.labels.* config values from §8c — are plain strings, not routed through __(). If your app supports multiple locales, wrap them yourself (__('permissions.squad_view_hint') instead of a literal string) — this addon won't do it for you. Shield's own standard CRUD labels (View, Create, Update, …) and RoleResource chrome (Save changes, Select All, …) already come from filament-shield's own translated lang files independently of this addon.


How it works internally

This addon does not override any class from filament-shield. Instead it uses the package's public extension point:

When a Page class exposes getShieldPagePermissions(), the addon intercepts the key builder and applies its three-part naming convention. All other entities (Resources, Widgets, regular Pages) are delegated back to the original builder unchanged.

Resource permissions use a two-part format matching Shield's own convention and are not created via shield:generate — only via shield:generate-enhanced-resources. This means the hook is not involved for Resources at all.

Component permissions work the same way as Resources with respect to the hook — the hook is not involved, since arbitrary Livewire components were never part of Shield's Page/Resource/Widget discovery pipeline in the first place. shield:generate-enhanced-components discovers them independently by scanning the configured components.scan_paths for classes using HasComponentShield, rather than iterating a panel's registered entities.


Changelog

See CHANGELOG.md.

License

MIT — see LICENSE.md.

Credits


All versions of filament-shield-enhanced with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
bezhansalleh/filament-shield Version ^4.2|^4.3
filament/filament Version ^4.0|^5.0
illuminate/contracts Version ^11.28|^12.0|^13.0
illuminate/support Version ^11.28|^12.0|^13.0
spatie/laravel-package-tools Version ^1.92
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package agroezinger/filament-shield-enhanced contains the following files

Loading the files please wait ...