Download the PHP package faithfm/laravel-simple-permissions without Composer

On this page you can find all versions of the php package faithfm/laravel-simple-permissions. 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 laravel-simple-permissions

laravel-simple-permissions

A simple way to define user permissions in your Laravel application:

[!TIP]

Notice the special '|' character that can be used to test multiple (ORed) permissions in a single gate

[!NOTE]

This package is the Authorization (AuthZ) component of our overall AuthN/AuthZ design pattern that we deploy for our apps. (Our Faith FM Laravel Auth0 Pattern package is more opinionated than this generic package, and includes a number of published template files that may be less helpful for a wider audience, but you're welcome to use them if they are helpful.)

Installation + Configuration:

Usage:

You can now test user permissions using regular Laravel Authorization Gate checks! (See examples above)


Advanced Usage: Vue front-end

LaravelUserPermissions.js is a helper library that allows additional permission-checks to be performed in the front-end.

This helper assumes that user permissions are passed from back-end to front-end using a global javascript LaravelAppGlobals variable (which is usually passed by the Blade file). Specifically it is looking for the existence of the global LaravelAppGlobals.user.permissions property.

In the examples below we will primarily consider the fourth row of the sample user_permissions table above:

Simple permission checks use the laravelUserCan() function:

More complex restrictions checks/filtering test user capabilities against JSON settings stored in the restrictions field. In our example above, a call to the laravelUserRestrictions('use-app') function returns:

The status property is injected along with any JSON data in the restrictions field, and is set to one of the following values:

The example below tests these conditions, and also checks to see if an app variable "currentItem" starts with the value of the "filter" property.

[!IMPORTANT]

You should not rely solely on front-end code to enforce important security features. These should be performed in the back-end as well.

Sample code to pass permissions via LaravelAppGlobals to front-end:

The following sample code shows one way the 'user' object (including permissions) can be passed to your front-end Vue app via the LaravelAppGlobals front-end variable.

In your Route/Controller:

Blade file:


Extended Usage: Laravel back-end

An equivalent of the javascript laravelUserRestrictions() function has not yet been implemented in the back-end to perform more complex testing based on the restrictions field. In the mean-time you could probably use something like this:


All versions of laravel-simple-permissions with dependencies

PHP Build Version
Package Version
Requires php Version ^7.0|^8.0
illuminate/support Version >5.0
laravel/framework Version >5.0
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 faithfm/laravel-simple-permissions contains the following files

Loading the files please wait ....