Search by

leuchtfeuer / mautic-segmentcrud-bundle

LeuchtfeuerDigitalMarketing

Console command to create / modify / delete segments, or to clear their content

Package info

github.com/Leuchtfeuer/mautic-SegmentCrud-bundle

Homepage

Type:mautic-plugin

pkg:composer/leuchtfeuer/mautic-segmentcrud-bundle

Statistics

Installs: 0

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

1.1.2 2026-09-25 13:32 UTC

README

Console tooling to create or update lead segments by alias or id, and optionally clear segment membership in two ways: --clear deletes rows from lead_lists_leads (soft), or --permanent-clear sets manually_removed = 1 on active rows while keeping the records (useful for Databridge-style / prep workflows where you need one or the other).

Overview

  • Symfony command: leuchtfeuer:segment:prepare
  • Behaviour is gated by a plugin integration: the command runs only when the integration is installed and published (see below).

Requirements

Tip

Other releases of this plugin may target different Mautic versions.

  • Mautic 5.x
  • PHP 8.1 or higher

Installation

Composer

Install the package and ensure it is deployed under plugins/LeuchtfeuerSegmentCrudBundle (see Composer extra.install-directory-name).

Manual Installation

  1. Download / copy the plugin into the Mautic plugins directory.

  2. The folder name must be LeuchtfeuerSegmentCrudBundle.

  3. In the Mautic UI as an administrator: Plugins → Install/Upgrade Plugins.

    Or with shell access from the Mautic project root:

    php bin/console cache:clear
    php bin/console mautic:plugins:reload

Configuration

The console command checks that the integration is published. If it is disabled, the command exits with an error and asks you to enable it.

  1. Log in as an administrator.
  2. Open Settings (cog) → Plugins (or Integrations, depending on your Mautic layout).
  3. Open Leuchtfeuer Segment CRUD (integration key: SegmentCrud).
  4. Publish / enable the integration and save.

Until this is done, leuchtfeuer:segment:prepare will refuse to run.

Usage

From the Mautic project root (where bin/console lives):

php bin/console leuchtfeuer:segment:prepare --help

That lists all options (--alias, --id, --name, --desc, --noupdate, --nocreate, --clear, --permanent-clear, --batch-size, etc.).

Typical examples (after the plugin is published):

# Soft clear: remove all membership rows for this segment (batched DELETE on lead_lists_leads)
php bin/console leuchtfeuer:segment:prepare --alias=my-segment-alias --clear

# Permanent clear: set manually_removed = 1 on every active membership; rows remain (batched UPDATE)
php bin/console leuchtfeuer:segment:prepare --alias=my-segment-alias --permanent-clear

# Same by numeric segment id (segment must already exist)
php bin/console leuchtfeuer:segment:prepare --id=123 --clear

# Update display name only
php bin/console leuchtfeuer:segment:prepare --alias=my-segment-alias --name="New name"

Use --help for the authoritative option list and defaults (e.g. --batch-size applies to both --clear and --permanent-clear).

Do not pass --clear and --permanent-clear together — the command exits with an error.

  • --clear: batched DELETE — no rows left for that segment in lead_lists_leads.
  • --permanent-clear: batched UPDATE … SET manually_removed = 1 WHERE manually_removed = 0 — active membership (what Mautic treats as “in segment”) becomes zero, but history rows stay in the table.

Mautic events

This command is a direct console path and does not participate in Mautic’s event system the way UI- or API-driven segment flows do. In particular, do not expect the same subscribers / follow-up events (e.g. segment membership or list change events) to be dispatched or to run in the same order as in core segment processing. If you rely on custom plugins that listen for segment-related events, validate behaviour separately or trigger those side effects by another supported mechanism.

Tests

Unit tests (plugin repository)

In this plugin directory, after composer install:

composer test
# same as:
composer phpunit

That runs PHPUnit with --testsuite unit (Tests/Unit).

CI (GitHub Actions)

Pull requests use the shared mautic-ci-runner workflow: PHP CS Fixer, PHPStan, Rector, Twig lint, unit tests, and functional tests (MySQL/MariaDB matrix) against supported Mautic 5.x and PHP versions.

Functional tests (local / full Mautic)

Functional tests extend Mautic\CoreBundle\Test\MauticMysqlTestCase and need a complete Mautic tree with MySQL. In DDEV, from the project root:

ddev exec env APP_ENV=test APP_DEBUG=0 KERNEL_CLASS=AppTestKernel \
  bin/phpunit -d memory_limit=2G \
  plugins/LeuchtfeuerSegmentCrudBundle/Tests/Functional

If you use DDEV, from the host:

export DB_SERVER_VERSION=10.3.0-MariaDB   # match your MariaDB; use e.g. 5.7 for MySQL 5.7

Functional tests also expect DB client tools (mysqldump / mysql) behaviour compatible with MauticMysqlTestCase; running inside DDEV avoids many host-only mismatches.

Troubleshooting

  • Command says the plugin is disabled: enable Leuchtfeuer Segment CRUD under Plugins / Integrations and save.
  • After deploying files manually: php bin/console cache:clear and php bin/console mautic:plugins:reload.
  • Alias vs CLI: segment aliases are normalized when saved in Mautic; use the stored alias (as in the UI or database) when calling --alias.

Credits

Developed by Leuchtfeuer Digital Marketing GmbH.

Author

Leuchtfeuer Digital Marketing GmbH