PHP to execute CLI commands

Hello, I am new to this forum and I have very limited skills with PHP :smiley:

I face the following problem

On my website - that is hosted on a shared hosting account - I have installed a email automation software called MAUTIC

This application needs CLI commands to run properly / to correct system failures

Sometimes you may need to use the command line with Mautic. Here follows a list of the CLI commands that can be used.

You can find this list (and others - for example commands relating to Doctrine and other vendors) by typing app/console at the command line in your Mautic directory.

In this directory the following commands need to be executed

cache:clear
cache:warmup --env=prod
mautic:segments:update
doctrine:schema:update --dump-sql
doctrine:schema:update --force

The path for the app is: https://www.mywebsite.com/contacts/

I hope that an experience PHP coder can help me with the code needed so I can coppy the code in a PHP file “repair-correct.php” and upload this file to my website’s public-html directory

I want to run the code with using the URL https://www.mywebsite.com/repair-correct.php

Thank you so much for your help!

Warm regards,
Tony

I don’t know if what is required will be allowed in shared hosting, because CLI uses different options and means that it makes the server susceptible to malicious scripts to allow them.

What does the repair-correct file need to do and when? Is it something that could be automated so you don’t have to access the system from the web instead?

Find out if you may use SSH and run some commands like a CLI on remote…
On some servers you have to prefix php before the commands for example:

php app/console cache:clear

Warning: Be carefull with the commands as you wrote. It are strong not secured commands that may screw up your database. Make a backup first!

Maybe, I could use cron jobs instead of using a PHP file - thanks for the idea!

Thanks for your reply. I asked my web hosting provider if I could use SSH and they told me that they have made it available for me.

I think, I can solve my problem now directly.

Again, thanks a lot!

Sponsor our Newsletter | Privacy Policy | Terms of Service