Markus Michalski FAQ

Contact Requests: Installation and Operation

Sylius Contact Requests Plugin - installation via Composer (Packeton), update, deleting old requests regularly, uninstall in the right order

Deutsche Version

Back to overview

Contact Requests: Installation and Operation

Live Demo: Try this and other plugins live — no installation, no risk: demo.markus-michalski.net

Installation

This repository is private and served through Packeton (https://packeton.markus-michalski.net). You get the access credentials after purchasing a license or being granted access.

{ "repositories": [{ "type": "composer", "url": "https://packeton.markus-michalski.net" }] }
composer require mmd/sylius-contact-requests-plugin
  1. Register the bundle in config/bundles.php:

    Mmd\SyliusContactRequestsPlugin\MmdSyliusContactRequestsPlugin::class => ['all' => true],
    
  2. Import the Admin route, for example in config/routes/mmd_sylius_contact_requests.yaml:

    mmd_sylius_contact_requests_admin:
        resource: "@MmdSyliusContactRequestsPlugin/config/routes/admin.yaml"
    

    This plugin ships no shop routes of its own. It only hooks into the mail sending of Sylius' contact form through two decorator services, so a second import line for shop.yaml is not needed.

  3. Run the setup command:

    bin/console mmd:contact-requests:setup
    

    mmd:contact-requests:setup runs only this plugin's single migration, never migrations of your application or other plugins. The command is idempotent: if the migration has already run, nothing happens, even after a composer update. If Sylius' own migrations are still open, it aborts and tells you to run doctrine:migrations:migrate first. It also checks whether the route from step 2 is imported and prints the matching snippet if not. It never writes to your config/ directory. The usual doctrine:migrations:migrate still works as an alternative. Run the command as the same user as your other console commands, and add --no-interaction in scripts.

From now on the plugin stores every request from the contact form in the shop and through the Shop API. No settings are needed, and there is no per-channel on/off switch (see Configuration).

Update

composer update mmd/sylius-contact-requests-plugin
bin/console mmd:contact-requests:setup --no-interaction
bin/console cache:clear

You can safely run the setup command again after every update: without a new migration, nothing happens.

Delete old requests regularly

Stored requests contain personal data (name, e-mail, message) and are never deleted automatically. Set up your own cron job for this:

Command Recommended interval Description
bin/console mmd:contact-requests:purge --older-than=90 weekly or monthly Permanently deletes every request older than the given number of days (default: 90)

Example crontab entry for the user that also runs your other console commands (adjust the path):

# every Monday at 03:00: delete requests older than 90 days
0 3 * * 1 cd /var/www/shop && bin/console mmd:contact-requests:purge --older-than=90 --no-interaction

There is no trash and no restore. A deleted request is gone for good.

Uninstall

The order matters, because Doctrine only knows the migration while the bundle is still registered:

  1. Remove the cron job for mmd:contact-requests:purge.

  2. With the bundle still registered, roll back the migration:

    bin/console doctrine:migrations:execute --down 'Mmd\SyliusContactRequestsPlugin\Migrations\Version20260904121117'
    
  3. Remove the route import and the bundle entry in config/bundles.php, then run composer remove mmd/sylius-contact-requests-plugin.

Instead of rolling back the migration, you can drop the table mmd_sylius_contact_requests_contact_request by hand. In that case you also need to remove the row Mmd\SyliusContactRequestsPlugin\Migrations\Version20260904121117 from the doctrine_migration_versions table.