kuzey beytar
kuzey beytar

Reputation: 3227

Creating a simple plugin system in php

I'am writing an online software. I need to integrate a simple plugin system in it like wordpress (add action, add filter etc.)

What is the simplest way to do it in PHP?

Upvotes: 0

Views: 1152

Answers (3)

William Linton
William Linton

Reputation: 860

Simple answer: The best way is to just write it yourself and find out.

Instead of assuming you need a plugin system, write your app first. Then you'll start to get an idea of exactly what your app needs.

Solving that problem will make you a much better programmer. And once you know your app intimately, and you're tired of re-writing code and reinventing the wheel, and you want to start simplifying it and making it reusable, then making a plugin system will be second nature. You won't even have to think about it.

Take a look at Eric S. Raymond's Rules of Unix Programming. They're inspiring, fun to read, and very relevant here.

Upvotes: 4

Julio Guerra
Julio Guerra

Reputation: 5661

A lot of design patterns exist to do so but the easiest and simplest way, to me, would be with a simple class interface followed by all your plugins.

Upvotes: 0

alex
alex

Reputation: 490233

You want to look at the Observer pattern.

The observer pattern (a subset of the publish/subscribe pattern) is a software design pattern in which an object, called the subject, maintains a list of its dependents, called observers, and notifies them automatically of any state changes, usually by calling one of their methods. It is mainly used to implement distributed event handling systems.

This article looks like a good starting point.

Upvotes: 1

Related Questions