PHPackages                             constpb/amo-placeholder - 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. constpb/amo-placeholder

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

constpb/amo-placeholder
=======================

The library is designed for working with placeholders of custom fields of AmoCRM entity models, needed to make dynamic message text

1.0.0(3mo ago)02MITPHPPHP &gt;=8.1

Since Feb 4Pushed 3mo agoCompare

[ Source](https://github.com/constpb2394/amo-placeholder)[ Packagist](https://packagist.org/packages/constpb/amo-placeholder)[ Docs](https://github.com/constpb/amo-placeholder)[ RSS](/packages/constpb-amo-placeholder/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (3)Versions (2)Used By (0)

Lib purposes
------------

[](#lib-purposes)

Main purpose of this lib is to provide functionality of creating text messages for client mailing, depending on given AmoCRM entity models.

Amo model supported
-------------------

[](#amo-model-supported)

- LeadModel
- ContactModel

How to use
----------

[](#how-to-use)

### Localization

[](#localization)

Before use set necessary localization (at now supported only en and ru).

```
LocaleService::setLocale('ru');
```

### Basic usage

[](#basic-usage)

```
$this->typeFactory = new CommonTypeFactory(); // creates inner representation of AmoCRM custom fields

$this->handlerFactory = new HandlerFactory($this->logger); // creates handler decides placeholder of given custom field looks like
$this->placeholderFactory = new PlaceholderFactory(); // creates placeholder of given custom field representing entity (like 'Lead') and name (like 'Name of lead')

$this->placeholderBuilder = new CommonPlaceholderBuilder($this->logger, $this->handlerFactory, $this->placeholderFactory); // creates an array of placeholders strings of given entity type

$this->customFieldMapper = new CustomFieldMapper($this->logger); // creates an inner representation of AmoCRM custom fields from Amocrm custom field model
$this->entityMapperFactory = new CommonEntityMapperFactory( $this->typeFactory, $this->logger); // creates an inner representation of AmoCRM entity from Amocrm entity model
$this->replacer = new CommonReplacer($this->logger, $this->handlerFactory, $this->placeholderFactory); // creates an array with placeholders values as key and model values as values

/**
 * parses given string template with placeholders and substitutes given model values
 */
$this->templateProcessor = new MessageTemplateProcessorService(
    $this->logger,
    $this->placeholderBuilder,
    $this->customFieldMapper,
    $this->entityMapperFactory,
    $this->replacer
);

$contactCustomFields = $amocrmClient->customFields(EntityTypesInterface::CONTACTS)->get();

$placeholders = $this->templateProcessor->getVariables(EntityTypeEnum::CONTACT, $contactCustomFields) // managers may choose placeholders from list during client message creation

// then

$contact = new ContactModel();
$contact->setName('John');

$template = 'Hello, {{Contact / Name of contact}}!';

$message = $this->templateProcessor->replaceVariables($template, $contact); // results in Hello, John!
```

### Explanations

[](#explanations)

1. If there is no value for given placeholder, it will be replaced with empty string.
2. Placeholders pattern consists of entity type and field name divided by '/' like {{Lead / Custom field name}}, so it may result in string of Lead entity even if there is no custom field named 'Custom field name' if `getVariables` method is used with type Lead but custom fields of Contact entity.

###  Health Score

34

—

LowBetter than 77% of packages

Maintenance80

Actively maintained with recent releases

Popularity2

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity43

Maturing project, gaining track record

 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

Unknown

Total

1

Last Release

103d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/4973bb9a6401c2a712e1c74398be8fdefa69e3cd3f614ccd0e17d990e301f1b5?d=identicon)[constpb2394](/maintainers/constpb2394)

---

Top Contributors

[![constpb2394](https://avatars.githubusercontent.com/u/39743582?v=4)](https://github.com/constpb2394 "constpb2394 (7 commits)")

---

Tags

textplaceholderamo

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/constpb-amo-placeholder/health.svg)

```
[![Health](https://phpackages.com/badges/constpb-amo-placeholder/health.svg)](https://phpackages.com/packages/constpb-amo-placeholder)
```

###  Alternatives

[froala/wysiwyg-editor

A beautiful jQuery WYSIWYG HTML rich text editor. High performance and modern design make it easy to use for developers and loved by users.

5.4k306.9k3](/packages/froala-wysiwyg-editor)[ckeditor/ckeditor

JavaScript WYSIWYG web text editor.

5234.2M76](/packages/ckeditor-ckeditor)[dflydev/placeholder-resolver

Given a data source representing key =&gt; value pairs, resolve placeholders like ${foo.bar} to the value associated with the 'foo.bar' key in the data source.

14414.6M3](/packages/dflydev-placeholder-resolver)[tinymce/tinymce

Web based JavaScript HTML WYSIWYG editor control.

1697.5M106](/packages/tinymce-tinymce)[nojimage/twitter-text-php

A library of PHP classes that provide auto-linking and extraction of usernames, lists, hashtags and URLs from tweets.

1241.9M7](/packages/nojimage-twitter-text-php)[w8tcha/ckeditor-wordcount-plugin

WordCount Plugin for CKEditor Editor

77470.2k](/packages/w8tcha-ckeditor-wordcount-plugin)

PHPackages © 2026

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