How to change to Composer based Mautic 7.x?

System: Ubuntu 24.04 - Mautic 7.0.1 - PHP version is: 8.3.6 - Maradb: 10.11.13
My Mautic is in /var/www/html/mautic

I’d like to swith to composer based installation.

First: I’m completely new about composer - but i think, i need to install the composer first?
ChatGPT gave me this as information - but i don’t trust it 100%

Can anyone confirm, that this is the right install-routine for the composer?
If we have here a 100% working methode i would put it in the official manual of Mautic (after i changed my installation myself and check if all is working).

Install Composer

curl -sS https://getcomposer.org/installer | php
sudo mv composer.phar /usr/local/bin/composer
composer --version

Go to the path above
cd /var/www/html

Create a new project (for Mautic 7):

composer create-project mautic/recommended-project:^7 mautic-new --no-interaction
New directory has been created: /var/www/html/mautic-new with Composer structure

Explaining this command:

composer create-project mautic/recommended-project:^7 mautic-new --no-interaction

:one:composer create-project
This is a Composer command that creates a new project from a package.
It downloads the package including all dependencies into a new folder.
Similar to “downloading a ZIP file + extracting it + installing libraries”—only automatic and clean.

:two: mautic/recommended-project:^7

  • mautic/recommended-project → the official Composer package name of Mautic.
  • ^7 → the version restriction, meaning:

Meaning of ^7 in Composer

  • ^ means: compatible versions within the major version 7
  • So ^7 = “7.x.x, but not 8.x.x”
  • Example: Composer could install 7.6.1 or 7.9.0, but never 8.0, because that would potentially be incompatible

In short: ^7 ensures that Composer only downloads updates within the Mautic 7 series, which maintains stability and compatibility.

:three: mautic-new

  • This is the name of the folder where Composer installs the project.
  • After execution, the result is: /var/www/html/mautic-new

:four: --no-interaction

  • Composer does not ask for confirmation or input.
  • Useful for automated installations or scripts, so the command runs without manual intervention.

In short

Teil Meaning
composer create-project New project created from a package
mautic/recommended-project Mautic-Package-Name
^7 Version: all 7.x-versions, no 8.x
mautic-new target-folder
--no-interaction no imputs necessary

:light_bulb: Tip:
If you want to install Mautic 6, for example, you would use ^6.
For future versions, such as 8.x, then use ^8.

Copy folders from the existing installation

Configurations

cp -a /var/www/html/mautic/app/config/local.php /var/www/html/mautic-new/app/config/

Plugins
cp -a /var/www/html/mautic/plugins /var/www/html/mautic-new/

Uploads (Dateien und Bilder)

cp -a /var/www/html/mautic/media/files /var/www/html/mautic-new/media/files
cp -a /var/www/html/mautic/media/images /var/www/html/mautic-new/media/images

Dashboards

cp -a /var/www/html/mautic/media/dashboards /var/www/html/mautic-new/media/dashboards

Themes

cp -a /var/www/html/mautic/themes /var/www/html/mautic-new/themes

Übersetzungen

cp -a /var/www/html/mautic/translations /var/www/html/mautic-new/translations

Save old installation & activate new

sudo mv /var/www/html/mautic /var/www/html/mautic-old
sudo mv /var/www/html/mautic-new /var/www/html/mautic

Setting rights:

sudo chown -R www-data:www-data /var/www/html/mautic
sudo find /var/www/html/mautic -type f -exec chmod 644 {} +
sudo find /var/www/html/mautic -type d -exec chmod 755 {} +
sudo chmod -R g+w /var/www/html/mautic/var/cache \
                     /var/www/html/mautic/var/logs \
                     /var/www/html/mautic/app/config \
                     /var/www/html/mautic/media/files \
                     /var/www/html/mautic/media/images \
                     /var/www/html/mautic/translations

Check Apache:

Apache should access /var/www/html/mautic/public
Apache VirtualHost:

DocumentRoot /var/www/html/mautic/public
<Directory /var/www/html/mautic/public>
    AllowOverride All
    Require all granted
</Directory>

Delete Cache
sudo -u www-data php /var/www/html/mautic/bin/console cache:clear

Is that right? If yes, i would changed my installation and copy / adjust the way official manual for Mautic
If something is missed - or wrong - i need the experts here to adjust errors or add steps.
The result should be a changing tutorials for “beginners” like me.