https://github.com/cakephp/acl
Plugin for managing ACL in CakePHP applications.
https://github.com/cakephp/acl
acl cakephp cakephp-plugin php
Last synced: 7 days ago
JSON representation
Plugin for managing ACL in CakePHP applications.
- Host: GitHub
- URL: https://github.com/cakephp/acl
- Owner: cakephp
- License: other
- Created: 2014-05-22T12:58:38.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2024-04-01T16:59:50.000Z (about 1 year ago)
- Last Synced: 2024-05-28T04:38:49.978Z (11 months ago)
- Topics: acl, cakephp, cakephp-plugin, php
- Language: PHP
- Homepage:
- Size: 1.8 MB
- Stars: 112
- Watchers: 38
- Forks: 90
- Open Issues: 13
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.txt
Awesome Lists containing this project
- awesome-cakephp - Acl plugin - Managing ACL as database approach. (Authentication and Authorization)
README
# CakePHP Acl Plugin
[](https://travis-ci.org/cakephp/acl)
[](https://codecov.io/github/cakephp/acl)
[](LICENSE.txt)> ℹ️ **The ACL Plugin is not actively maintained by the CakePHP core team.** ℹ️ PR's to fix problems are welcome.
>
> As a modern alternative please check out the [Authentication](https://github.com/cakephp/authentication) and [Authorization](https://github.com/cakephp/authorization) plugins.A plugin for managing ACL in CakePHP applications.
## Installing via composer
You can install this plugin into your CakePHP application using [composer](https://getcomposer.org).
The recommended way to install composer packages is:
```
composer require cakephp/acl
```Then in your `src/Application.php`:
```php
public function bootstrap()
{
parent::bootstrap();
$this->addPlugin('Acl');
}
```## Creating tables
To create the ACL requires tables, run the following `Migrations` command:
```
bin/cake migrations migrate -p Acl
```## Attaching the behavior
Add the `Acl` behavior to your table so it will automatically create an `aco` whenever a new record is saved:
```php
public function initialize(array $config)
{
parent::initialize($config);$this->addBehavior('Acl.Acl', ['controlled']);
}
```## Updating the entity
Before you can start using the behavior, you MUST add the `parentNode()` method to the corresponding `Entity` file or the `AclBehavior` will not be able to determine the parent->child relationships. Also make make sure the method returns either null or a parent Model reference.
```php
public function parentNode() {
return null;
}
```> If things went well you should now see an entry appearing in the
> `acos` database table whenever you save a new record.## Running tests
Assuming you have PHPUnit installed system wide using one of the methods stated
[here](https://phpunit.de/manual/current/en/installation.html), you can run the
tests for the Acl plugin by doing the following:1. Copy `phpunit.xml.dist` to `phpunit.xml`
2. Add the relevant database credentials to your phpunit.xml if you want to run tests against
a non-SQLite datasource.
3. Run `phpunit`