Download the PHP package smarch/omac without Composer

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

This is probably only of use to me, but I have need of it in multiple apps so I packaged it up in case you want it too. :)


OMAC

A simple trait to allow basic authorization checks using whatever authorization package is desired. Currently supports Laravel Default, Shinobi, Sentinel and Entrust.

Installation

Installation is performed with composer.

:black_square_button: Composer

composer require "smarch/omac"

Usage

Where you want to use OMAC to check access, add the trait.

class YourController extends Controller
{
    use \Smarch\Omac\OmacTrait;

Once you have the OmacTrait in use, and you are happy with the authorization driver you are using (see parameters below), you can use the checkAccess() method of Omac by passing in the required permission to allow access.

Example of using OMAC to permit viewing an index of resources

/**
 * Display a listing of the resources.
 *
 * @return Response
 */
public function index()
{
    if ( $this->checkAccess('view.index') ) {
        $resources = Model::all();
        return view("index", compact($resources) );
    }

    return view("unauthorized", ['message' => 'Not authorized to view Index'] );
    // OR
    return false;
    // OR
    abort(401, 'Unauthorized action.');

}

Arguments

The checkAccess() method accepts both the $permission and an $arguments variable. So if your preferred authorization package accepts a second argument to its method, you can use it.

    if ( $this->checkAccess('update.post', $post) ) {

:hand: NOTE : Sentinel only accepts a $permission argument so you will not be able to pass in a second argument.

:hand: NOTE : Entrust only accepts a boolean (true/false) as it second argument.

Parameters (optional)

By default, OMAC is set to enabled and to use Laravel's built-in authorization can method. (Gate) If you wish to use a different authorization method, or to disable OMAC, you can change the parameters. You can do it in your class or method somewhere for a one-off usage, or you can set it on the constructor of your class to make the change for all the methods.

/**
 * constructor
 * 
 * @param boolean acl Whether or not ACL is enabled
 * @param string $driver Which ACL package to use
 */
public function __construct() {
    $this->acl = false;
    $this->driver = "sentinel";
}

:trident: Why "OMAC"?

I've been a DC geek for over 30 years now. While OMAC in DC is more of a "big brother is watching" type of thing, it still fits nicely with Object Managed Access Control. :smile:


All versions of omac with dependencies

PHP Build Version
Package Version
Requires php Version >=5.5.9
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 smarch/omac contains the following files

Loading the files please wait ....