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
Related
I am developing mobile application for existing magento website and the mobile application has its own web admin and web admin developed in core php (not in magento). Can we put the core php web admin code to magento /app/code/local/ folder ? and is it work with magento ?
Please help me on this.
We can consider Magento as an application that is constituted by modules. Each of this module does different functionalities, but still they are independent to each other. This property makes Magento highly extendable and powerful.
By default, Magento comes with lot of such individual modules. These modules are located inside app/code/core. Note that, this folder only holds Model and Controller logic parts. View logics are separated from this and it normally lies in app/design and skin folders.
If you need to extend Magento core functionality or if you need to add any new functionality, you have two options available.
Use an extension
Develop your own custom modules
For extension/pluggin, Magento uses app/code/community directory. This way core modules are seperated from extensions and it gives us lot of flexibility.
When you use your own modules to add any functionality, you probably need to add your module in app/code/local. This way, custom modules are seperated from both core and extensions.
When Magento looks for a module, it will first check that module in local directory. If it is not there, then it will check in community directory. If it is not there, again it will check in core directory. Finally it will check it in lib directory. This callback mechanism is the core concept that you need to understand , before start to develop your own extensions.
It is not necessary to put your custom module in app/code/local directory. You can put it in community or in core directory. This is because, the callback mechanism can pick up your module, irrespective of these three locations. However as I said earlier, three of this directories has its own purpose. So better use them properly as it demands.
Hope that makes lot of sense
From Magento Wiki,
Every custom module will be created in the directory:
/app/code/local
And this is the directory structure that you use to create one:
/app/code/local/<Namespace>/<Module>/
That way, we can have multiple modules under a single namespace.
Naresh, /app/code/local/ is used to put your custom developed plugin/extension for magento. it's main aim to have custom developed code and core code separate.
If in future you upgrade the version of magento than it overwrite/delete the code written in /app/code/core/ but leave the code as it is in /app/code/local/ and it's place where you can override the core block/helper/model as well.
you can't copy your code directly in to core, you have to create module/plugin to club your existing code with magento.
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.
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 am using this awesome framework during 6 months and I learnt a lot about it, but I wonder if it's possible to create an internal structure to simulate modules like in Codeigniter. I know there is the possibility to use plugins for that, but it seems too difficult to connect it together and pass info between them.
My goal is to get a joomla like modules, but how can i do that without changing the cakephp core? is that possible?
What I am doing for the project I have going on right now is to have the following
In my bootstrap.php
<?php
....
App::build( array(
'plugins' => array(
join( DS, array( null, 'Users', 'abryant', 'Sites', 'appName', 'tools' )),
),
...
));
?>
Then, I keep all of my utility plugins in the tools plugin folder. This is for plugins that you use as internal utilities that don't provide controller / action pairs. IE plugins for behaviors, components, stuff from github etc.
One of the plugins I always grab for my stuff is Eventful which allows you to handle event dispatching and receiving using event classes similar to controllers or models.
Then build a main AppController that has a corresponding AppControllerEvent class in the folder the instructions tell you to use. You can then keep your plugins folder clean for modules which provide controllers, views or some other direct user interaction.
You can use Eventful to broadcast events from plugins down to the App at the AppModel, or AppController sort of level. If you think about this carefully you can use an app level event to ask for responses from installed plugins and then cycle through a set of events to register blocks or inject information into the set view variables.
A lot opens up when you use events and think about how the events communicate with your app.
Well, you are right. Modules in Joomla are independent packages of code wich works like packages in linux (modules maybe depends on other modules), but all of them work over a core functionality. What I want to do is write a core over the CakePHP framework, wich includes the functionality to manage all kind of modules in the system, but I don't know what is the best way to modify CakePHP core to handle this situation...
I did this before with Codeigniter, and because of that I thought to come back to Codeigniter, but Cakephp helps me to create apps in less time... If it may be possible, it would be a great system.
Every module code should be inside its own directory, which includes a controller directory, models, views, config, etc... like a mini CakePHP app that extends the modified CakePHP core. I thought it can be done with plugins, but the way to interconnect them and pass info between them don't seem the best way to do it.
I hope you understand my explanation, sorry for my english.
Initially it seems very difficult, but I think it is the best solution for this problem.
Did you code plugins for all your modules? Or did you code the core in controllers, models, etc.. and extra modules inside plugins? It is weird to me to work this way in CakePHP.
I'll try to code all the modules apart, I mean a core plugin, settings plugin, modules plugin (to manage the other plugins), etc... And probably I'll use bootstraping.
Thank you very much for your answers and sorry for my bad explanation of my problem, but my idea was so general that I couldn't explain it better.
I have way too many modules in my application. Currently my modules are namespaced, but what I'd like to do is have a directory structure so I can get rid of this redundant and annoying namespacing.
For instance, for modules named "xModule1, xModule2, xModule3", I'd like to have a directory structure like this:
-x
-module1
-actions and templates
-module2
-actions and templates
-module3
- actions and templates
Surely the developers at symfony know that people would like to use their framework to develop large applications. So how is module organization like this done?
I've done a lot of work in Java/Spring, and because source is component scanned, you can arrange your controllers and jsp files in nicely organized hierarchies. Is this somehow possible with Symfony?
No, this is not possible with Symfony. The structure of your modules and their actions and templates is expected in a fixed file system layout and I haven't heard anything about that changing.
I've run into the same problem you're facing where a very large site ended up with 30+ modules in a single application. At first it seemed cumbersome but after dealing with it for a while I found that the single location to search for a specific module was in fact beneficial instead of having to guess through sub-structures until I got what I was after. Seeing that structure grow and grow also pushes me to respect adding new modules only when it's absolutely necessary, folding new functionality into existing modules and refactoring existing modules to work with new enhancements whenever possible.
Symfony does have auto-loading features that will work for your library folders however, allowing you to have lib/one/two/three/Object.class.php or any other structure you see fit.
If you have so many modules, you could consider to move some functionality into plugins (i.e. create your own plugins).
The benefit is that you can use this functionality also in other projects.
Or you can group your modules into applications. You can have as many applications as you want, not only backend and frontend.
I've wondered about the same thing, especially as many configuration files need to be set either at application level or individual module level. It could useful to be able to cascade configurations to a set of modules.
As mentioned above, it seems the available solutions are:
deal with lots of modules
create separate applications (which will create some wieldy duplication)
refactor your modules to be as efficient as practical (i.e. multiple controllers & views per module)