Download the PHP package sybio/permission-bundle without Composer

On this page you can find all versions of the php package sybio/permission-bundle. 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 permission-bundle

Permission Bundle

A Symfony bundle to manage permissions (authorizations) as Value Objects, with an integrated validation system and native integration with Symfony's security system.

Introduction

This bundle provides a modern and type-safe approach to managing permissions in your Symfony applications. Instead of using strings or constants, permissions are represented as immutable Value Objects, each having its own checker (equivalent to a handler) that contains the business logic for validation.

This approach offers better maintainability, better testability, and better IDE integration thanks to strong typing.

Advantages

✅ Type-safe : Permissions are typed objects, not strings
✅ Separation of concerns : Each permission has its own dedicated checker
✅ Symfony integration : Compatible with the security (Voter) and validation systems
✅ Auto-configuration : Checkers are automatically detected and registered
✅ Testability : Easy to test thanks to dependency injection
✅ Maintainability : Easy to extend with new permissions and maintain over time

Installation

If you're using Symfony Flex, the bundle will be automatically registered. Otherwise, register it manually in config/bundles.php:

Configuration

Configuration is optional. By default, the bundle uses the PERMISSION security attribute. You can customize it in config/packages/sybio_permission.yaml:

Creating a permission and its checker

1. Create the permission (Value Object)

Create a class that implements PermissionInterface:

2. Create the checker

Create a checker that implements PermissionCheckerInterface:

The checker is automatically detected and registered thanks to the bundle's auto-configuration.

Usage

Method 1: With the security system

Use the security system to check permissions:

Note that the attribute 'PERMISSION' is defined in the configuration and you can customize it. You can also use the Permission class as attribute, it will work : $this->isGranted(EditArticlePermission::class, new EditArticlePermission(....

Then get violations list if needed:

The power of this bundle is that you can also pass to the view why access was denied by reading violations.

Example with a controller

Method 2: With PermissionValidator

Thanks to the validator component, you can validate permissions directly with validation:

Method 3: With Twig Extensions

The bundle provides two Twig functions to check permissions directly in your templates.

Function has_permission()

This function returns a boolean indicating whether the permission is granted or not.

Usage:

The function takes:

Function permission()

This function returns a decision object containing both the granted status and the violations list.

Usage:

The returned object has:

Complete example

Here's a complete example with a (little) more complex permission:

License

MIT

Author

Sybio (Clément Guillemain)


All versions of permission-bundle with dependencies

PHP Build Version
Package Version
Requires php Version >=8.3
symfony/config Version ^7.1
symfony/dependency-injection Version ^7.1
symfony/http-kernel Version ^7.1
symfony/security-core Version ^7.1
symfony/twig-bundle Version ^7.1
symfony/validator Version ^7.1
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 sybio/permission-bundle contains the following files

Loading the files please wait ...