Mautic Community Forums

extending mautic

hi escopecz, please i need your help wishing not to bother you, actually i want to extend mautic by adding a topic to the list of the left pane which contains dashboard ,emails ,landing pages , campaigns… the question is how to do it , i took a look about symfony and get familiar with it, but am new to open source and don’t know how to start such thing (extending). so what is the key is it a plugin ? or something else ? i wish you tell me briefed steps about my issue and ill really appreciate it.

hi escopecz, please i need your help wishing not to bother you, actually i want to extend mautic by adding a topic to the list of the left pane which contains dashboard ,emails ,landing pages , campaigns… the question is how to do it , i took a look about symfony and get familiar with it, but am new to open source and don’t know how to start such thing (extending). so what is the key is it a plugin ? or something else ? i wish you tell me briefed steps about my issue and ill really appreciate it.

Hello, that’s actually a great question. Yes, if you want to extend Mautic, go with a plugin. To compose a plugin, inspire by the existing plugins (naming convention) and the core bundles. For example this is how you create a menu item:

https://github.com/mautic/mautic/blob/staging/app/bundles/AssetBundle/Config/config.php#L51-L63

ok thanks for the hint :slight_smile: just another question . i read about the mautic bundle generator . i download it (zip file) but dont know how to make it work. does it works ? generate a full bundle ? or should i write the plugin manually word by word ?

I haven’t heard about a Mautic bundle generator actually. So I can’t help with that.

actually i made a sample plugin to test it and place it in the plugins folder . then i tried to press install plugin from the plugin manager but i get ( 0 plugins installed …) could you help me just to get started not more . i don’t know why my plugins didn’t get installed.

The first thing to do when something is behaving funny during Mautic development: clear the cache. There is a command for it. Read about it here:
https://developer.mautic.org/#development-environment

If your plugin is not installed, and the cache is cleared, it has probably some naming convention broken. Hard to say where or what is it. The best would be if you’ll link here a Github repo where I could see the code. Also, it’s pity we are discussing it in a private thread and it won’t help anyone else.

actually i have prod cache in my app i already delete it but with no results . this is the sample plugin i did, please check it for me
https://drive.google.com/open?id=0By1rOlT63sKGc0lDNTRmdV96UXM

Try to implement these values to your config.php:

https://github.com/mautic/mautic/blob/staging/plugins/MauticCrmBundle/Config/config.php

am really sorry escopecz but also it didnt work after i implement the code you sent :frowning:
this is the link after i added the code : https://drive.google.com/open?id=0By1rOlT63sKGeDVrT0pBN2NtTFU

It works for me. Name the plugin in config.php with a unique name, clear cache and then you’ll see this:

Compile Error: Cannot redeclare class MauticMauticSocialMediaBundleControllerDefaultController

Rename your controller name to some unique name and you’ll be able to install the plugin.

actually i delete the prod cache manually not by command and there is no dev cache to delete it. still not working and am stuck can i let you connect my server via team viewer to check the plugin folder ? dont want to be rude but am really in need to it in my work escopecz

I also don’t want to be rude, but I don’t provide such level of support. I don’t even work on Mautic today but on another project.

ah ok bro dont mind you helped me alot am really thankfull bro , one last thing please can u check my folder finally is there any mistake ? i changed the plugin name in config.php and the controller name. and does it matter if i deleted the cache manually or by command ?? this is the last update : https://drive.google.com/open?id=0By1rOlT63sKGLTJwNzdQbVJiVUU

Now I’m getting

Runtime Notice: Declaration of MauticPluginMauticSocialMediaBundleMauticSocialMediaBundle::onPluginInstall() should be compatible with MauticPluginBundleBundlePluginBundleBase::onPluginInstall(MauticPluginBundleEntityPlugin $plugin, MauticCoreBundleFactoryMauticFactory $factory, $metadata = NULL)

You probably don’t use dev environment if the dev cache is not generated. Read https://developer.mautic.org/#development-environment

There is almost no difference if you use the command or just remove the directory. The command also generates the new cache, but cache is also generated automatically on refresh so the result is the same.

Good luck with your plugin. I hope you’ll help us write some better docs from your experience. It’d help others a lot.

am thankful bro , i really appreciate it . bubye

hi again escopecz, please wanna ask you something , i tried my plugin in the dev mode and i got the error you told me before. so am not able to enter the dev mode again due to the error which my plugin did, how can i fix that to enter the dev mode again ?

Heh, this is going to be a long development if we’ll consult every error message. Let’s look at what the error message says in more detail:

This is where the problem is:

Declaration of MauticPluginMauticSocialMediaBundleMauticSocialMediaBundle::onPluginInstall()

This is how PHP is suggesting to fix it:

should be compatible with MauticPluginBundleBundlePluginBundleBase::onPluginInstall(MauticPluginBundleEntityPlugin $plugin, MauticCoreBundleFactoryMauticFactory $factory, $metadata = NULL)

Your onPluginInstall method looks like this:

[code]static public function onPluginInstall(Plugin $plugin, MauticFactory $factory, $metadata = null)
{
if ($metadata !== null) {
self::installPluginSchema($metadata, $factory);
}

    // Do other install stuff
}[/code]

There is no use statement for

MauticPluginBundleEntityPlugin

and

MauticCoreBundleFactoryMauticFactory

so what PHP is ranting about is that the method in the parent class (MauticPluginBundleBundlePluginBundleBase::onPluginInstall) has 2 parameters which types are not the same as your onPluginInstall method has.

So the solution would be to add the use statements with those classes so the parameter types will be the same. But this is just my guess. I didn’t test it.

am really sorry if iam taking alot of ur time thank u bro and you were right i put the use statements for install and update and the error is gone but the plugin did nothing and the topic to the left pane is not added :s

hi escopecz i know you didnt miss me :slight_smile: but i do , just a typical question i changed something in my plugin and in the prod mode it is working fine while in the dev mode it is not responding even deleting the cache didnt solve the problem. any idea bro ?