PHPackages                             scaleplan/access - 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. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. scaleplan/access

ActiveLibrary[Authentication &amp; Authorization](/categories/authentication)

scaleplan/access
================

Access control system for Scaleplan

v0.1(8y ago)1168PHP

Since Nov 16Pushed 5y ago1 watchersCompare

[ Source](https://github.com/scaleplan/access)[ Packagist](https://packagist.org/packages/scaleplan/access)[ RSS](/packages/scaleplan-access/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (1)Dependencies (2)Versions (2)Used By (0)

Access
======

[](#access)

Access control system + check of argument types.

#### Installation

[](#installation)

`composer reqire scaleplan/access`

#### Initialization

[](#initialization)

```
cd vendor/scaleplan/access

./init schema data

```

where schema and data are optional parameters indicating the need to generate Access schema in the database and API URLs, files and entered in the configuration respectively.

#### Mechanics of work

[](#mechanics-of-work)

The controller method is called from outside the controller class. How this happens is unimportant.

If the method is public, or the comment in the method indicates the value of the *access\_no\_rights\_check*Directive the configuration, the system is not involved and the execution occurs as usual. If the method is private (access modifiers private and protected) and if you specify a special phpdoc tag treatment method system Access (value Directive access\_label configuration), then the database query that checks the possibility of execution of the method with the come settings for a specific user (user ID is specified when you create objects Access).

For example:

```
class User
{
/**
     * Get user object
     *
     * @accessMethod
     *
     * @param int $id - user identifier
     *
     * @return UserAbstract
     */
    protected static function get(int $id): UserAbstract
    {
//...
    }
}

```

This example will check the current user's access to the static get method of the User class for any values of the $id argument.

However, access can be defined to execute a method with specific arguments:

```
/**
     * Get user object
     *
     * @accessMethod
     *
     * @accessFilter id
     *
     * @param int $id - user identifier
     *
     * @return UserAbstract
     */
    protected static function actionGet(int $id): UserAbstract
    {
//...
    }

```

In this example, access will be allowed only if the value of the $id filter argument is included in the list of allowed values stored in the database (column *values* of the table *access\_right*). A list in the database will look like:

`ARRAY [',
