Download the PHP package brzez/access-policy-bundle without Composer

On this page you can find all versions of the php package brzez/access-policy-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 access-policy-bundle

symfony-access-policy

Overview

Access checker, inspired by Laravel.

It allows for checking access via simple can and cannot methods accessible via the brzez_access_policy.access_policy_provider service.

It also extends twig with those two methods as global functions.

can needs minimum 2 arguments:

It is also possible to pass additional variables to the can/cannot methods.

The 2nd arg is always used for finding the matching policy.

The rest are just passed to the policy *can()** method.

Policy needs to implement AccessPolicyInterface which requires the getPoliciedClass method. Policied objects are checked via

Which means that it will work for mocked entities. It's also possible to implement 'global' policies for interfaces / parent classes.

Policies are registered as services.

The policy service needs to be tagged as access_policy so it will be recognized by the access policy provider.

Installation

Enable the bundle in the kernel

Registering policies

In services.yml

Naming intent methods

When using can/cannot methods the intent is written in kebab-case, without the can/cannot word.

Example:

Usage

PolicyProvider can be accessed via container

Controllers can use Brzez\AccessPolicyBundle\Traits\AccessCheckerTrait which will extend the controller by adding:

It also adds twig global functions - can(...) and cannot(...) which can be used like this:

Example

Let's say we have SomeEntity and we need to check view access via our policy.

We need to create SomeEntityPolicy with canView method.

Link the policy to the entity

In app/config/services.yml

Now you can check access in the controller:

You can also check access in twig views:

Changelog


All versions of access-policy-bundle with dependencies

PHP Build Version
Package Version
No informations.
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 brzez/access-policy-bundle contains the following files

Loading the files please wait ....