PHPackages                             codemix/accessrestrictable - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Security](/categories/security)
4. /
5. codemix/accessrestrictable

ActiveLibrary[Security](/categories/security)

codemix/accessrestrictable
==========================

A Yii ActiveRecordBehavior that automatically applies conditions for access restriction to every query.

22321PHP

Since Aug 8Pushed 12y ago2 watchersCompare

[ Source](https://github.com/codemix/AccessRestrictable)[ Packagist](https://packagist.org/packages/codemix/accessrestrictable)[ RSS](/packages/codemix-accessrestrictable/feed)WikiDiscussions master Synced 3w ago

READMEChangelogDependenciesVersions (2)Used By (0)

AccessRestrictable
==================

[](#accessrestrictable)

This behavior adds automatic access restriction to your ActiveRecord queries.

By doing so it introduces a new security layer right inside the models. If any user tries to access resources that he doesn't have permission to, the query result will simply be empty.

Installation
------------

[](#installation)

We recommend to install the extension with [composer](http://getcomposer.org/). Add this to the `require` section of your `composer.json`:

```
'codemix/accessrestrictable' : 'dev-master'

```

> Note: There's no stable version yet.

You also need to include composer's autoloader on top of your `index.php`:

```
require_once __DIR__.'/protected/vendor/autoload.php';

```

Make sure to fix the path to your composer's `vendor` directory. Finally you also need to configure an `alias` in your `main.php`:

```
$vendor = realpath(__DIR__.'/../vendor');
return array(
    'alias' => array(
        'AccessRestrictable' => $vendor.'/codemix/AccessRestrictable/src/AccessRestrictable',
    ),
    ...
```

Configuration
-------------

[](#configuration)

To enable access restriction you have to attach the behavior to an ActiveRecord like so:

```
