Creating a plugin system like Wordpress with Laravel / PHP

This question has been listening to me for quite some time, I want to create cms, School Mnagement System, to be more specific, and what is important for me, makes this system plugin based, so that administrators can download and install plugins directly from the admin panel, for sure just like wordpress.

Now I read about wordpress Hooks , Actions and Filters , and to be honest, I can say that I'm just a little familiar with their functionality, but to apply the same functionality to the Laravel App ... it's a little difficult to understand, at least for me.

I also looked for this question and found that almost everyone offers packages, but while packages can work fine for other developers who want to use the packageโ€™s functionality, they cannot be easily installed by the user, and are not familiar with any programming language, and this is exactly what i want in my application.

Now, what I mean so far, as in Wordpress Actions and Filters , almost everything that I would like to use in Wordpress theme files (to make this part of the code flexible for adding plug-in functionality) should be called as functions, and a call of this Wordpress do_action () function is a kind of required path, which of course makes sense.

In this case, plugin developers can simply call add_action () / add_filter () in their files and put their plugins in the application stream. So that...

Basically, I ask here:

  • How to apply this functionality to a laravel application?
  • Is there an easier way than calling everything with the do_action () function?
  • Do I have to write some kind of file management module for downloading and updating plugins?

Again, I have to say that I am not very well versed in how Wordpress can achieve this functionality. Therefore, I may be mistaken in relation to the description mentioned above, but please, I appreciate any clarification on this subject if you can.

Thanks in advance for your understanding.

* PS I tried to be as clear as possible about the problem, and I am not looking for any specific method for the system that I am developing. I want to know the general / best methods (if there is a better way) to achieve this functionality, preferably in Laravel, but the general algorithm will still be very appreciated.

I know that many people have the same question and they solve this problem, so if you even provide a link to a useful article, it would be great. *

+5
source share
1 answer

I have been working as a Wordpress developer for a very long time, and I also have sufficient experience with Laravel ... and, frankly, making such functionality is not so difficult at all.

How?

First of all, you must understand that the web application that you create will have all the functionality, but you can enable or disable them only from the interface (admin panel / dashboard). In other words, your School Management System application actually has all the pre-installed features / functions, but you just let users turn it on / off. It is much simpler.

So, if, for example, for. if you want to provide attendance management functionality to someone, you will need to give the site administrator access to enable / disable it.

Why?

Wordpress has a built-in user interface for adding / updating plugins. But in Laravel, everything is code-based, so I think this is the easiest way (especially to make things in the application plug-in).

Actions

  • Create a website with a user interface, etc.
  • Create a configuration and migration file that displays the names of all the plug-ins that you allow the user to enable / disable.
  • Make a sync command that will sync all plugins in your application.
  • Use it to bring the page out of the frontend and manage its state from the backend (is_active, etc.) ...
  • Now that these plugins are active, make sure that the user (for example, moderator, editor) has access to manage them, for which you will obviously have to create roles / permissions and use Laravel Policies for such things.
  • Finally, only the administrator will be able to enable / disable the recording and no one else.

In the other part, where you want people to perform their own functions with filters / actions . I would say that this completely contradicts the part where you say Installing Laravel Packages isn't easy . Well, if you really want the developer to do this, why not immediately ask them to make a package for your application alone? Hmmmm .... Think about it :)

But even then, if you would like to create such functionality, create a simple class that the user can call, and the user can call his own functions ... Something like โ†’ SMSPlugin::do_action() . But then again, to create things like updating / removing a plugin, you will need to create your own plugin store and ask users to download it. Then you will have to make an API to constantly check for updates for all installed plugins and blah blah ... This is a very long procedure ... And I also donโ€™t think it is possible!

I hope I answered everything. Let me know in the comments if you have any doubts :)

+6
source

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


All Articles