Contact Requests: Installation and Operation
Sylius Contact Requests Plugin - installation via Composer (Packeton), update, deleting old requests regularly, uninstall in the right order
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
-
Register the bundle in
config/bundles.php:Mmd\SyliusContactRequestsPlugin\MmdSyliusContactRequestsPlugin::class => ['all' => true], -
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.yamlis not needed. -
Run the setup command:
bin/console mmd:contact-requests:setupmmd:contact-requests:setupruns 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 acomposer update. If Sylius' own migrations are still open, it aborts and tells you to rundoctrine:migrations:migratefirst. It also checks whether the route from step 2 is imported and prints the matching snippet if not. It never writes to yourconfig/directory. The usualdoctrine:migrations:migratestill works as an alternative. Run the command as the same user as your other console commands, and add--no-interactionin 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:
-
Remove the cron job for
mmd:contact-requests:purge. -
With the bundle still registered, roll back the migration:
bin/console doctrine:migrations:execute --down 'Mmd\SyliusContactRequestsPlugin\Migrations\Version20260904121117' -
Remove the route import and the bundle entry in
config/bundles.php, then runcomposer remove mmd/sylius-contact-requests-plugin.
Instead of rolling back the migration, you can drop the table
mmd_sylius_contact_requests_contact_requestby hand. In that case you also need to remove the rowMmd\SyliusContactRequestsPlugin\Migrations\Version20260904121117from thedoctrine_migration_versionstable.