Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7088929
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T07:51:39+00:00 2026-05-28T07:51:39+00:00

I am trying to build a basic plugin system like the kind you often

  • 0

I am trying to build a basic plugin system like the kind you often find in a CMS like WordPress. You have a folder of plugins which tie into the main system’s operation through event notifications using an Observer or Event design pattern.

The problem is it’s impossible for the system to know which events the plugin wants to act upon – so the system has to load each plugin for every page request just to find out if that plugin is actually needed at some point. Needless to say, that’s a lot of wasted resources right there–in the case of WordPress, that adds up to several extra MB of memory for each request!

Are there alternative ways to do this?

For example, is there a way to load all this once and then cache the results so that your system knows how to lazy-load plugins? In other words, the system loads a configuration file that specifies all the events that plugin wishes to tie into and then saves it in APC or something for future requests?

If that also performs poorly, then perhaps there is a special file-structure that could be used to make educated guesses about when certain plugins are unneeded to fulfill the request.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T07:51:40+00:00Added an answer on May 28, 2026 at 7:51 am

    I do have a plugin management tool, but I only every used it with predominantly procedural plugins, and with all includes usually loaded at once. But for an event-based and lazy-loading API I could imagine using shallow wrappers for the plugin management, and resorting to autoloading for the actual extensions.

    <?php
      /**
       * api: whatever
       * version: 0.1
       * title: plugin example
       * description: ...
       * config: <var name="cfg[pretty]" type="boolean" ...>
       * depends: otherplugin
       */
    
     $plugins["title_event"] = "TitleEventClass";
     $plugins["secondary"] = array("Class2", "callback");
    ?>
    

    In this example I’d assume the plugin API is a plain list. This example feature-plugin-123.php script would do nothing but add to an array when loaded. So even if you have a dozen feature plugins, it would only incur an extra include_once each.

    But the main application / or plugin API could instead just instantiate the mentioned classes (either new $eventcb; for the raw classnames or call_user_func_array for the callbacks). Where in turn it would offload the actual task to an autoloader. Thus you have a dual system, where one part manages the list, the other locates the real code.

    I’m thereby still imaganing a simple config.php which just lists plugins and settings like this:

    <?php
    include_once("user/feature-plugin-123.php");
    include_once("user/otherplugin2.php");
    include_once("user/wrapper-for-htmlpurifier.php");
    $cfg["pretty"] = 1;
    

    Again taking in mind that these are just wrappers / data scripts, with the plugin description for managability. One could as well use an actual register_even() API and define an additional wrapper function in each. But listing classnames seems the simplest option.

    The aforementioned management tool is kind of rusty and ugly: http://milki.include-once.org/genericplugins/
    But it’s uneeded if you just need a list (sql table) and no settings management. That overhead is only for prettyprinting the plugin meta data and keeping a human-readable config.php.

    In conclusion:

    spl_autoload() on the include_path, and a simple event->classname registry, one wrapper script each, simply included all at once.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to build a basic application which will have 2 separate components which
Im trying to build a extremely basic content management system. I want to do
I am trying to build a basic templating engine. Like the template engines already
I am trying to build a basic drop down menu with jquery. I have
I'm a JavaScript novice trying to build a basic share button as a learning
I am currently trying to build a very basic serial shell with my arduino.
I am trying to build an application to simulate some basic spheres moving around.
I'm trying build a method which returns the shortest path from one node to
Trying to build sslsniff on a RHEL 5.2 system here. When compiling sslsniff on
I'm trying to build a basic POP3 mail client in C/++, but I've run

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.