Symfony - What is required to create a plugin?

I am looking through the Symfony documentation to learn how to create a plugin. However, the two textbooks seem to provide a lot of additional information (e.g. models, etc.).

What would I like to know, what is the absolute minimum requirement to get a controller and template working from the plugins directory?

For example, just an index action and the corresponding Hello World pattern.

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

Any advice is appreciated.

Thanks.

+4
source share
2 answers

To accomplish what you requested, you will need the following:

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

Then you will need to enable the plugin in ProjectConfiguration, and also enable the module in your settings.yml for any applications that you want to use.

Routing is not performed automatically. You need to add routes manually in routing.yml, or you can create a listener and add / add routes when routing.load_configuration fired. USING the second option also involves creating the PluginConfiguration class, in which listeners connect to the event through the event dispatcher.

Basically, the plugin follows the same basic structure as the application, in addition to everything that is optional. Regardless of whether you need to do anything, it really depends on what your plugin does. You can also take a look at using sfTaskExtraPlugin , it has a task to create a basic plugin skeleton and a plugin module skeleton.

+7
source

some examples

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

 $this->enablePlugins('MyPlugin'); 

include the module in your settings.yml

 all: .settings: enabled_modules: [my_module] 
0
source

Source: https://habr.com/ru/post/1338732/


All Articles