PHPackages                             angelxmoreno/cakephp-linked-entities - 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. [Framework](/categories/framework)
4. /
5. angelxmoreno/cakephp-linked-entities

ActiveCakephp-plugin[Framework](/categories/framework)

angelxmoreno/cakephp-linked-entities
====================================

LinkedEntities plugin for CakePHP 3.x

v1.0.3(7y ago)13MITPHPPHP &gt;=5.6

Since Aug 28Pushed 7y ago1 watchersCompare

[ Source](https://github.com/angelxmoreno/cakephp-linked-entities)[ Packagist](https://packagist.org/packages/angelxmoreno/cakephp-linked-entities)[ Docs](https://github.com/angelxmoreno/cakephp-linked-entities)[ RSS](/packages/angelxmoreno-cakephp-linked-entities/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (5)Dependencies (7)Versions (6)Used By (0)

LinkedEntities plugin for CakePHP 3.x
=====================================

[](#linkedentities-plugin-for-cakephp-3x)

[![Build Status](https://camo.githubusercontent.com/c3dec7c4c7ae2d032c66d56c60b57d20ec2a9612636e743a91a573980b7af41f/68747470733a2f2f7472617669732d63692e636f6d2f616e67656c786d6f72656e6f2f63616b657068702d6c696e6b65642d656e7469746965732e7376673f6272616e63683d6d6173746572)](https://travis-ci.com/angelxmoreno/cakephp-linked-entities)[![Codacy Badge](https://camo.githubusercontent.com/8ca78add27109cefa19ce4ffb8a7654e086cf8db4b055857be89976b45d1cdd8/68747470733a2f2f6170692e636f646163792e636f6d2f70726f6a6563742f62616467652f47726164652f6434656430323663633437643439363139663639303537373564613637656636)](https://www.codacy.com/app/angelxmoreno/cakephp-linked-entities?utm_source=github.com&utm_medium=referral&utm_content=angelxmoreno/cakephp-linked-entities&utm_campaign=Badge_Grade)[![Maintainability](https://camo.githubusercontent.com/2b08cf9cc6b515cfc75779b70dd6bb9cac035cc80df3c03ed4695697d7e72690/68747470733a2f2f6170692e636f6465636c696d6174652e636f6d2f76312f6261646765732f63653530303163613663366439656464616666312f6d61696e7461696e6162696c697479)](https://codeclimate.com/github/angelxmoreno/cakephp-linked-entities/maintainability)[![Test Coverage](https://camo.githubusercontent.com/d347bac3938fe6ce904a623044ab5bc12e6f5d2d384f1cdf4cf42f3bba05e899/68747470733a2f2f6170692e636f6465636c696d6174652e636f6d2f76312f6261646765732f63653530303163613663366439656464616666312f746573745f636f766572616765)](https://codeclimate.com/github/angelxmoreno/cakephp-linked-entities/test_coverage)[![License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.txt)[![Minimum CakePHP Version](https://camo.githubusercontent.com/17f13041564bb2fc335bf8bac5a2cf760772512c8c523907511023e4d00de8f2/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f43616b655048502d332e782d7265642e737667)](https://cakephp.com/)[![Minimum PHP Version](https://camo.githubusercontent.com/e97290c4047b8fc1152177fc8110cab416f31f18159b722b6b633a210a198861/687474703a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253345253344253230352e362d3838393242462e737667)](https://php.net/)

LinkedEntities allows the ability to associate your User Entities with any other Entities ( including self referencing ) by a category type. It adds shortcut functions to your User Table for ease of use.

Features
--------

[](#features)

- Ability to define User-to-Entity relationship via a polymorphic table
- Define relationship by category
- Automatic relationship of Entity-to-User
- Shortcut methods based on relationship name

Examples
--------

[](#examples)

```
$this->Users->addStarredProject($user, $project);
$this->Users->removeFollowedUser($user, $otherUser);
```

Requirements
------------

[](#requirements)

- CakePHP 3.x
- PHP &gt;=5.6

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

[](#installation)

You can install this plugin into your CakePHP application using [composer](http://getcomposer.org).

The recommended way to install composer packages is:

```
composer require angelxmoreno/cakephp-linked-entities
```

Next you need to [load the plugin](http://book.cakephp.org/3.0/en/plugins.html#loading-a-plugin) by adding the following to your `config/bootstrap.php` file:

```
// config/bootstrap.php
Plugin::load('LinkedEntities', ['bootstrap' => true]);
```

Finally, create the required tables using `cakephp/migrations`:

```
bin/cake migrations migrate -p LinkedEntities
```

Or import the sql schema found in `config/schema`.

Setup
-----

[](#setup)

1. In your `config/app.php` define a new config key called `LinkedEntities` ( see [configuration](#configuration) )
2. In your UsersTable add the `LinkedEntities.LinkableEntityUser` behavior like so:

```
$this->addBehavior('LinkedEntities.LinkableEntityUser');
```

3. Optionally add the `LinkedEntities.LinkableEntity` behavior to the corresponding Table classes defined in your config. i.e:

```
$this->addBehavior('LinkedEntities.LinkableEntity');
```

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

[](#configuration)

Sample configuration:

```
// config/app.php
'LinkedEntities' => [
    'UserModel' => 'Users',
    'link_types' => [
        'star' => 1,
        'follow' => 2,
    ],
    'links' => [
        'StarredProjects' => [
            'name' => 'UserStars',
            'className' => 'Projects',
            'linkType' => 1
        ],
        'FollowedProjects' => [
            'name' => 'Followers',
            'className' => 'Projects',
            'linkType' => 2
        ],
        'FollowedUsers' => [
            'name' => 'Followers',
            'className' => 'Users',
            'linkType' => 2
        ]
    ]
]
```

With the configuration above ( after adding the behavior ) you will have 6 new methods available to your UsersTable:

1. $this-&gt;Users-&gt;addStarredProjects($user, $project);
2. $this-&gt;Users-&gt;removeStarredProjects($user, $project);
3. $this-&gt;Users-&gt;addFollowedProjects($user, $project);
4. $this-&gt;Users-&gt;removeFollowedProjects($user, $project);
5. $this-&gt;Users-&gt;addFollowedUsers($user, $otherUser);
6. $this-&gt;Users-&gt;removeFollowedUsers($user, otherUser);

#### UserModel parameter

[](#usermodel-parameter)

A string defining the plugin.name of your UsersTable ( defaults to `Users` )

#### link\_types

[](#link_types)

An array as a int =&gt; string ( this saves the int provided under the table column `type` )

#### links

[](#links)

An array as relationship name =&gt; settings Settings have the following keys

- name: The name of the relationship from the perspective of the linked entity ( the reverse relationship name )
- className: The name of the table to associate the user to
- linkType: the int value corresponding to one of the defined `link_types`

Reporting Issues
----------------

[](#reporting-issues)

If you have a problem with the plugin please open an issue on [GitHub](https://github.com/angelxmoreno/cakephp-linked-entities/issues).

License
-------

[](#license)

This plugin is offered under an [MIT license](https://opensource.org/licenses/mit-license.php).

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~2 days

Total

5

Last Release

2806d ago

Major Versions

v0.0.0 → v1.0.02018-09-02

### Community

Maintainers

![](https://www.gravatar.com/avatar/58aebae1bf475954887c4c975a24950aa32c0dd34026400fa0303f7a43672389?d=identicon)[angelxmoreno](/maintainers/angelxmoreno)

---

Top Contributors

[![angelxmoreno](https://avatars.githubusercontent.com/u/363479?v=4)](https://github.com/angelxmoreno "angelxmoreno (34 commits)")

---

Tags

cakephp-plugincakephp3phppolymorphismcakephp3cakephp-pluginpolymorphism

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/angelxmoreno-cakephp-linked-entities/health.svg)

```
[![Health](https://phpackages.com/badges/angelxmoreno-cakephp-linked-entities/health.svg)](https://phpackages.com/packages/angelxmoreno-cakephp-linked-entities)
```

###  Alternatives

[cakephp/debug_kit

CakePHP Debug Kit

86514.0M137](/packages/cakephp-debug-kit)[cakephp/bake

Bake plugin for CakePHP

11211.2M157](/packages/cakephp-bake)[friendsofcake/bootstrap-ui

Bootstrap front-end framework support for CakePHP

3492.1M32](/packages/friendsofcake-bootstrap-ui)[cakephp/app

CakePHP skeleton app

3831.7M1](/packages/cakephp-app)[cakephp/localized

CakePHP Localized Plugin

218595.6k5](/packages/cakephp-localized)[cakephp/elastic-search

An Elastic Search datasource and data mapper for CakePHP

86766.6k8](/packages/cakephp-elastic-search)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
