Download the PHP package darrylkuhn/enforce without Composer

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

Enforce

Enforce is an add on for Laravel4 and provides an elegant way to define custom data access enforcers on your Eloquent ORM models.

Quick start

In the require key of composer.json file add the following

"darrylkuhn/enforce": "dev-master"

Run the Composer update comand

$ composer update

In config/app.php in the $aliases array replace the existing 'Eloquent' key with 'Enforce\Model':

Configuration

Enforce uses the standard Laravel config. Create app/config/enforce.php with the following:

Of course you can set this to true if you'd like but read throught he entire quickstart before doing so (there are good reasons to initialize your application with enforce off.

Usage

Your models should continue to extend Eloquent. Behind the scenes they're really extending Enforce\Model which in turn extends \Illuminate\Database\Eloquent\Model.

Your models now inherit a few new static methods including enforceOnRead() and enforceFilter().

This filters out any models who's id doesn't match the id of the currently authenticated user. Now calls to will return filtered results. To be a little more useful let's say you wanted to allow "admins" to access all models - you could implement the following:

enforceFilter() can accpet complex keys (e.g. evaluates just fine.)

If necessary You may bypass enforcement by explicitly setting enforcement to false in the call

Startup

In some cases it's adventageous to leave enforcement off until your app has reached some state. In the example above if enforcement is on and we do not explicity set enforcement to false when calling the authentication process will fail. This is because the rule requires a valid authenticated user to access user models and the authentication system uses the user model to authenticate - chicken meet egg. There are several ways to solve for this; you can of course flag calls in the authentication subsystem but this may require hacking the Laravel core (which is not recommended). Assuming you're using a filter to authenticate a user prior to routing my recommendation is to initialize the app with the enforcement off () and then add a filter which flips it to true once the authentication is complete. For example in add the following filter to filters.php

Then include it in the appropriate routes call:

This will first authenticate the user and then turn enforcement on.


All versions of enforce with dependencies

PHP Build Version
Package Version
Requires php Version >=5.4.0
illuminate/support Version 4.x
laravelbook/ardent Version 2.x
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 darrylkuhn/enforce contains the following files

Loading the files please wait ....