D
D
Daniil Sidorov2020-07-02 19:22:35
Yii
Daniil Sidorov, 2020-07-02 19:22:35

How to create a universal site extension?

Hello. I have the following:

  • Website written in Yii2
  • Module written for this site

This module makes some modifications to site files. It consists of several pages. I want to make this module universal so that it works not only with this site. But I don't quite understand how to do it.

I have the following ideas:

1. Rewrite on a microframework and put it in the folder with the site
Rewrite the module using some kind of microframework (FatFree, Slim, etc.). I simply transfer the resulting module to the server and write the routing rules (I don’t quite understand how). As a result, the module will be available at: example.com/module
A similar principle is implemented in the Textolite static page management system . But there is only one page, and I have several of them.

2. Place the module on a subdomain
I'm taking the entire module and submitting it to a subdomain. There is no point in rewriting it in a microframework. It's easier to just make it look like a Yii2 site.

Perhaps the described methods are not viable, because. I just described my thoughts from my head and I'm not sure that this is generally practiced. Plus, I don’t quite understand what to do if the module is written in PHP, and the site, for example, in Python. Will the module work in this case?

I have been looking for some information on this issue for a long time, but I have not found anything. I'm completely confused and can't understand anything. Can you please tell me which direction to go?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim, 2020-07-02
@DaniLaFokc

1. This option is generally well applicable for more modern frameworks, but Yii2 is quite old. It does not support PSR standards, which makes it very poorly compatible with others. That is, it is impossible to write such a module for Yii and connect it to the symphony, as well as vice versa. In addition, Yii uses Active Record, and Symfony uses Doctrine. Therefore, you can only take out some components and connect them in your projects. It will be difficult with a separate module. The Yii module can only be used there. If you go this way, then you need to move this package to the repository and include this package through the composer. Inside the project, it remains to set up the config, set up dependencies through DI. Example .
2. The second option is more flexible. This is more about microservices. Applications will interact through the API. In this case, it doesn’t matter to you what kind of framework and base it is. Modern large systems are exactly like that. However, this is a complex system that requires a lot of knowledge and time.
If I were you, when designing in Yii2, I wouldn't worry about it. Firstly, this iodvl vryat who will need it. Secondly, it is not compatible with other frameworks. If you need such a module - just copy it to another project. If you feel that it changes often and you need compatibility with other projects - take it out into a package and connect it through the composer.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question