Dan
Dan

Reputation: 1085

Symfony - What is required to create a plugin?

I've been going through the Symfony documentation in order to find out how to create a plugin. However, the two tutorials seem to give a lot of extra information (for example models etc).

What I'd like to know is, what is the absolute minimum requirement in order to get a controller and template working from a plugin directory?

For example, just an index action and a corresponding 'Hello World' template.

Also, is the routing for this automatic or do I have to manually change something?

Any advice appreciated.

Thanks.

Upvotes: 4

Views: 2571

Answers (2)

Sergey Kharchishin
Sergey Kharchishin

Reputation: 484

some examples

enable the plugin in you ProjectConfiguration go to 'core\config\ProjectConfiguration.class.php' and add next code in setup()

$this->enablePlugins('MyPlugin');

enable the module in your settings.yml

all:
  .settings:
    enabled_modules:  [my_module]

Upvotes: 0

prodigitalson
prodigitalson

Reputation: 60413

To do what youre askign you would need the following:

MyPlugin/
  modules/
    my_module/
      actions/
        actions.class.php
      templates/
        indexSuccess.php

You would then need to enable the plugin in you ProjectConfiguration and also enable the module in your settings.yml for any apps you want to use it.

Routing is not automatic. You need to add routes manually to routing.yml or you can create a listener and appends/prepends the routes when routing.load_configuration is fired. USing the second option would also imply creating a PluginConfiguration class where you listeners connect to the event via the event dispatcher.

Basically a Plugin follows the same basic structure as an application - except pretty much everything is optional. Whether or not you need to do somethign really depends on what your plugin does. Also you might want to take a look at using sfTaskExtraPlugin it has a task for generating a basic plugin skeleton and a plugin module skeleton.

Upvotes: 7

Related Questions