Installing plugin breaks console

Your software
My Mautic version is: 2.16.4 (but it looks like it also doesn’t work in 3.2.2, although I haven’t tested it yet)
My PHP version is: PHP 7.2.34
My Database type and version is: MySQL 5.7.32
My Composer version is: 1.10.19

Your problem
My problem is: After resetting my MacBook I had to reinstall Mautic. After a clean install of Mautic (using the zip downloaded from Github), the console works. But when I install (using composer) a small extension I wrote (which works on other servers with the same Mautic version and php7.2.21, haven’t tested 7.2.34 yet) the console doesn’t work anymore and I get the error shown below. (This is logged to the terminal, not the log file).

The plugin I wrote is GitHub - bastolen/mautic-message-extension, which has no other dependencies then mautic/composer-plugin.

The error points to MauticApiBundle, which is located just fine by VS Code with app/bundles/ApiBundle/MauticApiBundle.php as reletive path.

These errors are showing in the log:
PHP Fatal error: Uncaught Error: Class ‘Mautic\ApiBundle\MauticApiBundle’ not found in /Users/bastolen/git/mautic/mautic2/app/AppKernel.php:160
Stack trace:
#0 /Users/bastolen/git/mautic/mautic2/vendor/symfony/http-kernel/Kernel.php(431): AppKernel->registerBundles()
#1 /Users/bastolen/git/mautic/mautic2/app/AppKernel.php(264): Symfony\Component\HttpKernel\Kernel->initializeBundles()
#2 /Users/bastolen/git/mautic/mautic2/vendor/symfony/framework-bundle/Console/Application.php(62): AppKernel->boot()
#3 /Users/bastolen/git/mautic/mautic2/vendor/symfony/console/Application.php(117): Symfony\Bundle\FrameworkBundle\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#4 /Users/bastolen/git/mautic/mautic2/app/console(43): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#5 {main}
thrown in /Users/bastolen/git/mautic/mautic2/app/AppKernel.php on line 160

Fatal error: Uncaught Error: Class ‘Mautic\ApiBundle\MauticApiBundle’ not found in /Users/bastolen/git/mautic/mautic2/app/AppKernel.php:160
Stack trace:
#0 /Users/bastolen/git/mautic/mautic2/vendor/symfony/http-kernel/Kernel.php(431): AppKernel->registerBundles()
#1 /Users/bastolen/git/mautic/mautic2/app/AppKernel.php(264): Symfony\Component\HttpKernel\Kernel->initializeBundles()
#2 /Users/bastolen/git/mautic/mautic2/vendor/symfony/framework-bundle/Console/Application.php(62): AppKernel->boot()
#3 /Users/bastolen/git/mautic/mautic2/vendor/symfony/console/Application.php(117): Symfony\Bundle\FrameworkBundle\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#4 /Users/bastolen/git/mautic/mautic2/app/console(43): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#5 {main}
thrown in /Users/bastolen/git/mautic/mautic2/app/AppKernel.php on line 160

Steps I have tried to fix the problem:
Reinstalling PHP, Composer and Mautic.

After some more testing I found the reason of it breaking. It has to do with the origin of the Mautic installation. When you install it using a downloaded zip and then install the plugin using composer, it does not work, but when you clone the repo (I cloned tag 2.16.3 to test) from Github, it works without any problems.

I think this has to do with the vendor map which is included in the zip download, but is not included in the git clone.

When updating Mautic 2 you get warned about using a cloned version, in stead of a downloaded one. Is there a way to download Mautic using the zip, but still install plugins using composer?

What happens if you run composer update?

Also, try using composer v1 and not the current release. I’m not familiar with the error message you’re seeing, but it’s worth a try.

Ah, didn’t even think of that… But unfortunately, it didn’t work. It resulted in this, which cleared the whole vendor map of all the dependencies:
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 0 installs, 0 updates, 142 removals

I use composer1.10.19. When using composer 2 I get different errors, so decided against trying to get that to work :smiley: .

Thanks for the idea. But I think I’ll recommend my client to just install the plugin with the folder itself.

Might be an idea for Mautic to include the composer.json and composer.lock files in the build zip. I think (will test this later) this will also fix my problem. The only thing I wonder is if that is excluded with a reason?

You might want to follow the Composer Initiative that was announced at Mauticon 2020. I don’t have the JIRA/Confluence links though the Slack Channel can be found at: https://mautic.slack.com/archives/C01E8F6T2HM

1 Like