First off, this isn't really a programming question but more of a programming concept question. Basically, I've built a bespoke PHP framework to speed up deployment on my end and I want some kind of plugin system in place that will allow me to add specific features to the base of the framework (like the SQL class or maybe a Twitter package) that will allow me to throw them into a folder and not have to actually edit the base for every new project.
Any ideas of the best way of going about this?
Here is a nicely written post by #ircmaxell on how to do that and what are the options:
Handling Plugins In PHP
Also check out:
Best way to allow plugins for a PHP application
what im doing in my cms:
for each plugin i make a folder latin-named of this plugin's name.
i create a /translations folder in there too. Check here.
have a single php file that has 2 basic functions, the plugin_install and plugin_uninstall (you know, things to happen on install/unistall like tables creation/drop)
create a special page of your system that reads these plugins, installed and not and give an on/off switch so users can install/unistall them.
load these single files mentioned above by a single call to include_once on top of your index page (or administration page) so to include whatever functionality they offer.
enabled plugins will be loaded (include_once) from your main page, and also their functionality, so each plugin can call each other's as well.
Related
I'm looking to add an image upload and comment area to an already existing site. Not wanting to reinvent the wheel I'm wondering if there are any "drop in" ways to handle user management and security.
I've begun looking at frameworks like Codeigniter, but as far as I can see they need to be installed in the root of the system and as I said, the rest of the site is already there.
I also noticed that Symfony has a standalone security suite for PHP but I didn't see a user management component.
I guess going further down the DRY "reinvent the wheel"...is there any already existing open source framework that has members pages where they can upload images. I currently work in php, but I'm open to suggestions.
Thanks.
Well, It seems you need something like cms,
and you are asking this from framework(which cms does). I will suggest you to go with cms, For php there lots of cms:
Druapl
Joomla
So, you do not write any code for your requirement, just drop modules into folder, and turn on them.
If you really want framework, then I would suggest you go with module based framework like yii. I has tons of modules, that you can include and use it, But they are not ultimate as cms's modules. In yii it is called exnetnsion
here is some extensions:
yii-user-management
Comments
If I were you I would go with cms's. For this kind of DRY things, They are the best and built in for this purpose.
If all you want is the ability to upload images and have users comment, then why not incorporate the functionality of an existing image gallery into your application? Most of those will already include user management. This website lists some of the more common galleries: http://www.design3edge.com/2010/08/26/best-free-and-open-source-php-image-galleries/. There is bound to be one you like in that list.
I want to create a blog-like website. At the begining I'll need a simple one person blog software, but in the future I'd like to have full access to the code and database (control the way posts are organized, offer special forms for creating new posts, allow users to register, implement a rating system, etc.)
What's the best solution for this? Is there a specific tool that will generate a database and php files, to which I'll have access, or should I code everything from zip?
I know Wordpress and Joomla are good blogging tools, but couldn't figure out whether I'll be able to freely redesign a blog that was created using those tools.
Wordpress is an open-source, flexible website infrastructure that is pluggable; and also quite simple to setup without any code modifications. It will generate its own database files and is capable of upgrading itself with minimal administrative overhead.
If you choose at a later date to expand the blog, you can manipulate and customize the theme (100% of what the end-users see), as you see fit.
Wordpress also has a strong plugin repository that may provide extended functionality without any need to code. For example, a post rating plugin already exists that shouldn't require coding to implement;
http://wordpress.org/extend/plugins/rate-this-page-plugin/
Just install wordpress, you'll have full access to the code and database, and it supports writing plugins to extend functionality. You can change page layout with their template engine.
Writing a blog from scratch is not a simple job
Just use Wordpress for now.
There are plenty of plugins to customize Wordpress
You can later develop your own plugins or write a new weblog system and migrate to it.
I'll promise when getting familiar with Wordpress. you won't leave it anymore!
Ok, this is kind of non-descriptive, but I wish to make a site in which I am able to add and remove "functions" via adding and removing php modules.
Basically, is it possible to make a site like a framework where you can insert and remove various php modules, similar to how you can enable and disable modules in any other program
Does this make any sense? :)
The way to go is design the Interface of your core application to the various plugins (or modules...) .
For example, you can decide that all plugins must have a certain directory structure.
This enables, for example your core libary to know where to find view files, new classes etc.
You might want to decide that All plugins have a the same name init file, where you write all the plugin initialization codes, same with other events (init, end etc).
All plugins that are to integrate into a specific menu in your core app should have a menue.php or some other, strictly named and structured configuration file that will tell your core library which menu to integrate it and what will be the texts etc etc.
CORE APPLICATION
The core application should have hookups in various important places, hookups that plugins can use/overidde to change behavior of the core application.
I would also suggest adding events, which is similar to behaviors, just that this time the core app triggers it and calls all functions who where registered to the event.
SUGGESTION
While I personally do not like Elgg too much, the way they designed it will let you understand pretty well how to design a FW which is easily expendable with plug-ins (try tha same with Joomla, wordpress).
You can do both procedural and objected-oriented ways.
Write bunch of functions or classes and then include or require that file
when you using them.
include
include_once
require
require_once
can be used to use those functions and classes
I'm thinking of building a plugin based application.
At the moment, I am not sure what type of plugins will be used so I don't have a requirement.
I wish to know how such applications are designed so I can start my application around that.
Does anyone have any experience with this? I don't mind what sort of system it is or what your plugins do. What I want are some ideas on how others have achieved this so I can formulate and make my own.
Thanks.
I use this for all of my plugins: http://failover.co.za/2010/10/20/writing-a-pluggable-php-application-part-1/
If the plugins are going to be built by people who won't be editing the script, then you can just include the file for the plugin.
I think it's better for you to work with MVC Framework and then create an application core (modules and all apps need and require this), then think global and create other apps and modules.
Also I suggest you look at an Open Source CMS like Wordpress, Drupal, etc.
I have to develop frontend/backend application using cakephp.
can you give me advice how should i develop them, using same cakephp library?
or I have to develop them using separate cakephp libraries?
I am confused - cakePHP would be used to implement both.
PHP would be used to implement the server-side backend. The same "project" would also contain HTML, JS, CSS, etc that will be used to render the front-end within the browser. Any PHP "views" will also execute code on the back-end, although any HTML output will be rendered on the frontend.
Does that help at all? Or am I missing something?
If by frontend/backend, you mean an application with a user interface (frontend) and an administration interface (backend), then you want to refer to the Prefix Routing section of the manual. This will allow you to have separate flow and interfaces (controller/view) for each type of user while sharing the same data (models).
If by frontend/backend, you mean an application (frontend) that communicates with another server application (backend) using web services, then you want to look at the Additional Class Paths section of the manual. This will allow you to share common classes with two (or more) separate applications.
Note: the above links are for CakePHP 3.x, though these features have existed in one form or another since v1.2.
Not quite sure if I understood you correct, but if I did:
You can set up multiple projects using the same cake-core files. The core files don't even need to be placed in the webroot folder..
http://book.cakephp.org/view/35/Advanced-Installation
For your own sanity, you should regard the backend management as part of the same project as the frontend.
The systems I have built generally use view-type methods for the public view and crud-type methods for the admin view. How you lock down the admin is your choice. Personally I don't like the default admin prefix way. I use login and ACL - Mark Story's tutorial on http://book.cakephp.org/ is superb. With that you can password protect methods.
CakePHP is very flexible and extensible and you can make the administration as simple or as flexible as you like.