PHPackages                             remp/crm-family-module - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. remp/crm-family-module

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

remp/crm-family-module
======================

CRM Family Module

4.4.0(6mo ago)019.0k↓39.6%1[1 PRs](https://github.com/remp2020/crm-family-module/pulls)MITPHPPHP ^8.1

Since Jul 24Pushed 5mo ago6 watchersCompare

[ Source](https://github.com/remp2020/crm-family-module)[ Packagist](https://packagist.org/packages/remp/crm-family-module)[ Docs](https://remp2030.com)[ RSS](/packages/remp-crm-family-module/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)DependenciesVersions (54)Used By (0)

CRM Family Module
=================

[](#crm-family-module)

[![Translation status @ Weblate](https://camo.githubusercontent.com/f1aef4ae8d5a857947e8d02045117db4cb859b83a2d9e5a54ed780a43113cb14/68747470733a2f2f686f737465642e7765626c6174652e6f72672f776964676574732f72656d702d63726d2f2d2f66616d696c792d6d6f64756c652f7376672d62616467652e737667)](https://hosted.weblate.org/projects/remp-crm/family-module/)

Family module is an extension to Subscriptions module providing parent/child relation between subscriptions. Parent subscription is able to trigger generation of child subscriptions via `family_requests`.

**WARNING**: Module is close-to-production quality, but expect some major breaking changes in the future (e.g. dropping of redundant tables, changing master/slave names).

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

[](#installation)

Add `remp/crm-family-module` via repository or package to your `composer.json` file and install it to your CRM skeleton.

Enable installed extension in your `app/config/config.neon` file:

```
extensions:
	# ...
	- Crm\FamilyModule\DI\FamilyModuleExtension
```

Usage
-----

[](#usage)

Family module needs to know which *subscription types* are meant to be *parents* and what subscription types should the child subscriptions have.

To do that, please seed the relations via `FamilySubscriptionTypesRepository::add()` method:

- `donationMethod`. Available values are:
    - `copy`: Child subscriptions will copy start/end date of its parent.
    - `fixed_days`: Child subscriptions will start at the time of activation and last fixed amount of days (implementation is currently not available).
- `count`. Number of child subscriptions to create when parent subscription is created.
- `is_paid`. Indicator used to flag whether child subscriptions should be counted as *paid* or not.

Anytime new master subscription is created, handler will create requests with codes that can be shared with other users so they can activate their access.

These codes can be accessed via two channels:

- As activation URLs in customer zone. You can enable the default widget in your own module by attaching following widget to the placeholder:

    ```
    namespace Crm\DemoModule;

    class DemoModule
    {
        public function registerLazyWidgets(\Crm\ApplicationModule\Widget\LazyWidgetManagerInterface $lazyWidgetManager) {
            $lazyWidgetManager->registerWidget(
                'frontend.subscriptions.top',
                \Crm\FamilyModule\Components\FamilyRequestsListWidget\FamilyRequestsListWidget::class,
                300
            );
        }
    }
    ```
- As family codes via API. You can access all available family codes with parent's account token via [`/api/v1/family/list`](#get-apiv1familylist) API. These codes can be then activated via [`/api/v1/family/activate`](#post-apiv1familyactivate) API.

### ExtendFamilyExtension

[](#extendfamilyextension)

You can use `ExtendFamilyExtension` subscription type extension method to extend your family/company subscriptions.

If CRM is creating new subscription with subscription type with this extension method, it tries to find all actual family subscriptions. If there is one, new subscription is appended after the actual. Otherwise the new subscription starts immediately (ignoring other non-family subscriptions).

The extension is registered automatically. If `FamilyModule` is enabled, you should be able to select it in your subscription type form.

### Renewal of child subscriptions

[](#renewal-of-child-subscriptions)

If the parent user account renews family/company subscription and new subscription starts at the same time as the previous one ends, child accounts are given new (renewed) subscriptions too. It's done automatically by event handler `\Crm\FamilyModule\Events\NewSubscriptionHandler`.

This time gap between subscriptions can be configured within your main config. For example if you want to allow renewal only 7 days after end of the subscription:

```
services:
	# ...
	familyNewSubscriptionHandler:
		setup:
			- setSubscriptionsTimeGap('7 days')
```

You can also prevent copying activated family requests at all, by adding meta `keep_requests_unactivated=1` to payment meta table.

### Dynamic count of child subscriptions

[](#dynamic-count-of-child-subscriptions)

If you don't want to have static count of generated child subscriptions defined within `family_subscription_types.count`, you can set your family subscription's value `count` to 0 and define number of child subscriptions to generate within payment item count. Conditions:

- Type of payment item is `\Crm\SubscriptionsModule\PaymentItem\SubscriptionTypePaymentItem::TYPE`.
- Subscription type of payment item is family subscription type which is defined within `family_subscription_types` table with value 0.
- Payment item count is non zero.

Example of payment item set while creating payment from within admin interface:

[![Custom payment item setting for dynamic family subscription type](docs/family_subscription_type_with_dynamic_count_-_add_payment.png "Custom payment item setting for dynamic family subscription type")](docs/family_subscription_type_with_dynamic_count_-_add_payment.png)

In this case, handler `\Crm\FamilyModule\Events\NewSubscriptionHandler` generates 7 child subscriptions.

### Custom type and count of child subscriptions

[](#custom-type-and-count-of-child-subscriptions)

If you want to have opportunity to define own combination of subscription types and their count you can do it by creating customizable subscription type with following steps:

- Define payment items for master subscription as `\Crm\SubscriptionsModule\PaymentItem\SubscriptionTypePaymentItem::TYPE` which will represent slave subscription types.
- Payment items must have meta (`payment_item_meta`) information with key `subscription_type_item_id` and value that refer to slave subscription type.
- Create family subscription type (`family_subscription_types`) with master subscription and previously defined and slave subscription type let `null`.

Admin interface in case of customizable subscription types is selected handles differently - display additional options for subscription type count and price.

Example of creating the payment of family subscription with customizable subscription type:

[![Admin form with customizable options](docs/family_form_with_customizable_options.png "Admin form with customizable options")](docs/family_form_with_customizable_options.png)

By the creating of payment for family subscriptions the payment items are created according counts and prices entered in admin form. In this case, handler `\Crm\FamilyModule\Events\NewSubscriptionHandler` generates 6 child subscriptions (5 of WEB type and 1 of KLUB type).

API documentation
-----------------

[](#api-documentation)

All examples use `http://crm.press` as a base domain. Please change the host to the one you use before executing the examples.

All examples use `XXX` as a default value for authorization token, please replace it with the real tokens:

- *API tokens.* Standard API keys for server-server communication. It identifies the calling application as a whole. They can be generated in CRM Admin (`/api/api-tokens-admin/`) and each API key has to be whitelisted to access specific API endpoints. By default the API key has access to no endpoint.
- *User tokens.* Generated for each user during the login process, token identify single user when communicating between different parts of the system. The token can be read:
    - From `n_token` cookie if the user was logged in via CRM.
    - From the response of [`/api/v1/users/login` endpoint](https://github.com/remp2020/crm-users-module#post-apiv1userslogin) - you're free to store the response into your own cookie/local storage/session.

API responses can contain following HTTP codes:

ValueDescription200 OKSuccessful response, default value400 Bad RequestInvalid request (missing required parameters)403 ForbiddenThe authorization failed (provided token was not valid)404 Not foundReferenced resource wasn't foundIf possible, the response includes `application/json` encoded payload with message explaining the error further.

---

#### GET `/api/v1/family/list`

[](#get-apiv1familylist)

Lists all available family codes of parent's account to share.

##### *Headers:*

[](#headers)

NameValueRequiredDescriptionAuthorizationBearer *String*yesUser token of parent account.##### *Example:*

[](#example)

```
curl -s –XGET http://crm.press/api/v1/family/list \
-H "Content-Type:application/json" \
-H "Authorization: Bearer XXX"
```

Response:

```
{
    "codes": [
        {
            "code": "1dwupidm1gfdsbvcxbxcvb6527dni",
            "master_user_id": 1,
            "status": "created",
            "subscription_type_code": "donation_from_company_year_online",
            "slave_user_id": null,
            "created_at": "2019-05-24T12:40:28+02:00",
            "updated_at": "2019-05-24T12:40:28+02:00",
            "opened_at": null,
            "accepted_at": null,
            "canceled_at": null,
            "expires_at": null
        }
    ]
}
```

---

#### POST `/api/v1/family/activate`

[](#post-apiv1familyactivate)

Activates provided family code and creates child subscription on the authenticated account.

##### *Headers:*

[](#headers-1)

NameValueRequiredDescriptionAuthorizationBearer *String*yesUser token of child account.##### *Payload*

[](#payload)

```
{
    "code": "1dwupidm1gfdsbvcxbxcvb6527dni", // required; Family code to activate.
}
```

##### *Example:*

[](#example-1)

```
curl -s –XPOST http://crm.press/api/v1/family/activate \
-H "Content-Type:application/json" \
-H "Authorization: Bearer XXX" \
-d '{
    "code": "1dwupidm1gfdsbvcxbxcvb6527dni"
}'
```

Response:

```
{
    "code": "1dwupidm1gfdsbvcxbxcvb6527dni",
    "subscription": {
        "start_at": "2020-06-02T09:45:15+02:00",
        "end_at": "2021-06-02T09:45:15+02:00",
        "code": "donation_from_company_standard_year_online",
        "access": ["web"]
    }
}
```

Work in progress...
-------------------

[](#work-in-progress)

**Fixed days child subscriptions**. Sometimes you might want to allow your users to generate child subscriptions independent of the master subscription that will last fixed amount of days. We plan to work on the implementation allowing to specify this in the `family_subscription_types`.

**Dynamic count of child subscriptions**. This will allow the ability to use single parent-child relation to generate dynamic number of child subscriptions based on a setting of parent subscription.

###  Health Score

51

—

FairBetter than 96% of packages

Maintenance70

Regular maintenance activity

Popularity26

Limited adoption so far

Community20

Small or concentrated contributor base

Maturity77

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

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 ~37 days

Total

53

Last Release

195d ago

Major Versions

0.38.0 → 1.0.0-beta22022-02-10

0.39.0 → 1.0.02022-03-29

1.2.0 → 2.0.02022-08-25

2.10.0 → 3.0.02024-01-22

3.7.0 → 4.0.02025-04-02

PHP version history (5 changes)0.17.0PHP ^7.1

0.29.0PHP ^7.3

0.35.0PHP ^7.4

2.0.0PHP ^8.0

3.0.0PHP ^8.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/7c733f9bd683c3814197d8a532b7da1ba1f631bb1efe1cde5f064feab1e24877?d=identicon)[rootpd](/maintainers/rootpd)

![](https://www.gravatar.com/avatar/a05541c0b35f43d95db5342210e1d9e64242888812d13f5b096df48b6aabd863?d=identicon)[msvitok](/maintainers/msvitok)

![](https://www.gravatar.com/avatar/2c30fdbc85cda35b94f7f59399918193a0289152281abcef344ec9ee82864177?d=identicon)[markoph](/maintainers/markoph)

---

Top Contributors

[![markoph](https://avatars.githubusercontent.com/u/6843562?v=4)](https://github.com/markoph "markoph (56 commits)")[![rootpd](https://avatars.githubusercontent.com/u/812909?v=4)](https://github.com/rootpd "rootpd (46 commits)")[![miroc](https://avatars.githubusercontent.com/u/1230714?v=4)](https://github.com/miroc "miroc (19 commits)")[![zoldia](https://avatars.githubusercontent.com/u/1526070?v=4)](https://github.com/zoldia "zoldia (16 commits)")[![Matefko](https://avatars.githubusercontent.com/u/22897457?v=4)](https://github.com/Matefko "Matefko (16 commits)")[![lubos-michalik](https://avatars.githubusercontent.com/u/63700066?v=4)](https://github.com/lubos-michalik "lubos-michalik (10 commits)")[![burithetech](https://avatars.githubusercontent.com/u/3502143?v=4)](https://github.com/burithetech "burithetech (5 commits)")[![weblate](https://avatars.githubusercontent.com/u/1607653?v=4)](https://github.com/weblate "weblate (3 commits)")[![davidkvasnovsky](https://avatars.githubusercontent.com/u/12381721?v=4)](https://github.com/davidkvasnovsky "davidkvasnovsky (2 commits)")

### Embed Badge

![Health badge](/badges/remp-crm-family-module/health.svg)

```
[![Health](https://phpackages.com/badges/remp-crm-family-module/health.svg)](https://phpackages.com/packages/remp-crm-family-module)
```

PHPackages © 2026

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