author | date | version | copyright | license | link | ||
---|---|---|---|---|---|---|---|
Virgil <[email protected]> |
2019-10-20 |
0.1.6 |
|
GPL3 |
commands.php can be used in environments where you do not have SSH access to run the Mautic command line tool: app/console
.
- Requirements βοΈ
- Installation π
- How to use π΄
- Mautic documentation π
- Related projects β οΈ
- Changelog π
- a Mautic installation
- works with Mautic 2.12+
- a webserver with PHP support
β οΈ WARNING
DO NOT leave the$secretphrase
asmautibot_happy
-
π½οΈ Download [
commands.php
] (or clone the repo) -
βοΈEdit your local copy of [
commands.php
]- π Change the
$secretphrase
parameter in the script to a new secret phrase so only you will be able to run the commands. - π¨ Optional: replace
$logo
with another<img src=
link.
- π Change the
-
π¦Copy your modifed
commands.php
to the root folder of your Mautic installation via SSH terminal, (s)FTP upload or carrier pigeon.βΉοΈ NOTE
This is the same level as Mautic'sLICENSE.txt
file and the directoryapp/
Add this to the server
block for the vhost.
server {
#server_name mautic.example.com;
#...
set $mautic_root /var/www/vhost1/mautic;
include snippets/mautic_cron.conf;
}
location /cron/ {
# URL would be https://mautic.example.com/cron/commands.php
root $mautic_root;
index commands.php;
location ~ /(commands|import)\.php(/|$) {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.2-fpm.sock;
#override SCRIPT_FILENAME
fastcgi_param SCRIPT_FILENAME $request_filename;
fastcgi_param HTTP_PROXY "";
fastcgi_read_timeout 600;
fastcgi_buffers 16 16k;
fastcgi_buffer_size 32k;
fastcgi_intercept_errors on;
fastcgi_param MAUTIC_ROOT $mautic_root;
}
}
When you open the URL, you are presented with a list of available commands. You can click on those to run the command, or use the Encoded URL link to a specific command in a cronjob/scheduler service, like Jenkins CI/CD.
-
π Open the
commands.php
URL with your browserhttps://mautic.example.com/commands.php?mautibot_happy
-
β Optional. Append
&pretty
to the URL to display a logo and basic navigationhttps://mautic.example.com/commands.php?mautibot_happy&pretty
command list
$allowedCmds = array(
'list',
'mautic:segments:update',
'mautic:campaigns:update',
'mautic:campaigns:trigger',
'cache:clear',
'mautic:emails:send',
'mautic:emails:fetch',
'mautic:emails:send --quiet',
'mautic:emails:fetch --quiet',
'mautic:broadcasts:send',
'mautic:broadcasts:send --quiet',
'mautic:broadcasts:send --channel=email',
'mautic:broadcasts:send --channel=sms',
'mautic:messages:send',
'mautic:campaigns:messages',
'mautic:campaigns:messages --channel=email',
'mautic:campaigns:messages --channel=sms',
'mautic:queue:process',
'mautic:webhooks:process',
'mautic:reports:scheduler',
'mautic:plugins:update',
'mautic:iplookup:download',
'mautic:assets:generate',
'mautic:segments:update --force',
'mautic:campaigns:update --force',
'mautic:campaigns:trigger --force',
'mautic:segments:update --max-contacts=300 --batch-limit=300',
'mautic:segments:update --max-contacts=300 --batch-limit=300 --quiet',
'mautic:segments:update --max-contacts=300 --batch-limit=300 --force',
'mautic:segments:update --max-contacts=1000 --batch-limit=1000',
'mautic:segments:update --max-contacts=1000 --batch-limit=1000 --quiet',
'mautic:campaigns:update --max-contacts=100 --quiet',
'mautic:campaigns:update --max-contacts=300 --quiet',
'mautic:campaigns:trigger --quiet',
'cache:clear --no-interaction --no-warmup --no-optional-warmers',
'cache:warmup --no-interaction --no-optional-warmers',
'mautic:social:monitoring',
'mautic:integration:pushleadactivity --integration=XXX',
'mautic:integration:fetchleads --integration=XXX',
'mautic:import --limit=600',
'mautic:import --limit=600 --quiet',
'mautic:dnc:import --limit=600',
'mautic:dnc:import --limit=600 --quiet',
'mautic:maintenance:cleanup --no-interaction --days-old=90 --dry-run',
'mautic:maintenance:cleanup --no-interaction --days-old=365 --dry-run',
'mautic:maintenance:cleanup --no-interaction --days-old=90',
'mautic:maintenance:cleanup --no-interaction --days-old=365',
'doctrine:migrations:status',
'doctrine:migrations:status --show-versions',
'doctrine:migrations:migrate --allow-no-migration --dry-run',
'doctrine:migrations:migrate --allow-no-migration --no-interaction',
'doctrine:migrations:migrate --allow-no-migration --query-time --dry-run',
'doctrine:migrations:migrate --allow-no-migration --query-time --no-interaction',
'doctrine:schema:update',
'doctrine:schema:update --dump-sql',
'doctrine:schema:validate',
'doctrine:schema:update --no-interaction --dump-sql --force',
'doctrine:schema:update --no-interaction --force',
'debug:swiftmailer',
'debug:router',
'doctrine:mapping:info',
'debug:event-dispatcher',
'mautic:install:data --no-interaction --force',
'mautic:contacts:deduplicate',
'mautic:unusedip:delete',
'mautic:dashboard:warm',
'mautic:campaign:summarize',
'mautic:update:find',
'mautic:update:apply --no-interaction --force',
);
-
π Find the URL encoded link to a command
https://mautic.example.com/commands.php?mautibot_happy&task=mautic%3Acampaigns%3Atrigger
-
π Request the URL
# min hr dom mth dow command */15 * * * * curl -L http://mautic.example.com/commands.php?mautibot_happy&task=mautic%3Acampaigns%3Atrigger
π‘ ProTip
curl
can also use this syntax:
curl -L 'http://mautic.example.com/commands.php?mautibot_happy&task=mautic:campaigns:trigger'
The output from the script will be sent to the browser so you can see the results just as if you ran this console
command from the shell.
Executing console mautic:campaigns:trigger
Triggering events for campaign 1
Triggering events for newly added contacts
2 total events(s) to be processed in batches of 100 contacts
0/2 [>---------------------------] 0%
2/2 [============================] 100%
2 total events were executed
0 total events were scheduled
Triggering scheduled events
0 total events(s) to be processed in batches of 100 contacts
0 total events were executed
0 total events were scheduled
Triggering events for inactive contacts
0 total events were executed
0 total events were scheduled
βΉοΈ NOTE
Access the complete Mautic documentation here.
- John Linhart's (@escopecz) original gist.
- @ChgoChad's update for Mautic 2.6.
- John Linhart's cronfig.io service and Mautic plugin
See CHANGELOG