Integrating Zend Framework and WordPress, Delegating page loads - php

I'm looking to have a full integration between Zend Framework and WordPress. For clarification, this does not mean I want to use Zend Libraries within WordPress, but rather delegating the page loads for a single site between both systems.
I've done a fair bit of research, I've come across several items, but nothing quite like what I'm looking for. I want to be able to load a page from the MVC if it exists and is available, otherwise load from WordPress or vice versa.
Now, I think I could approach this in a manner of combining the index files of WordPress and Zend Framework. Doing so, I would need to have a type of "check" against the incoming requests to decide which system to hit. I would suppose I would have a something in cache, containing all the Wordpress uri's to check against (that would be updated through a cron job / daemon), if not, serve up the bootstrap from Zend Framework.
Any suggestions would be greatly appreciated.

If all you're trying to do is have a Wordpress blog on a ZF site, then just put the blog on a subdomain or use mod_rewrite to rewrite all requests to blog/ to Wordpress.
If you're trying to do something more complicated that requires interaction between the two systems, I would suggest you route all requests to ZF (using the standard rewrite rules). Then let ZF decide whether or not it can handle the request, and if not, include the Wordpress index.php and let Wordpress do it's thing. See the answer here for some more detail: Converting a Brownfield PHP Webapp to Zend Framework.
You want to avoid making any changes to Wordpress itself if at all possible, as otherwise upgrading WP will become a painful process.

One thing I can imagine is that you pretest any request. So you send a sub-request with apache to wordpress, and if it's status 404 you delegate the request to zend.
All non 404 requests then need to be delegated (again) to wordpress.
But handle with care. I don't think this is really what you want.

Related

Can I have a Wordpress site with a CakePHP subsite?

I'm hoping to build a website which needs to be done quickly. The website itself should be fairly basic, so I was going to just do that in Wordpress. However, it also needs functionality to allow people to register and then interact (none of this appears on the website, just a link to the user login bit). I think it's going to be easier to build that bit in CakePHP as it has some very specific functionality that I don't think I'd find a WP plugin for.
Is there a way that I can build my website.com in Wordpress and then have something like my website.com/userarea where user area is built in CakePHP?
Yes it's possible, but requires a rather esoteric configuration of your webserver, and that's assuming you are proposing to implement the cakephp part with a front controller architecture. Even if you are a nginx/apache guru I'd recommend running the two components under different vhosts.

Is it possible to have zend modules and non-zend side by side

We have a php based website we want to gradually migrate to zend framework. I imagined we could have three new components developed on the framework and the rest as they are in the old website.
Is it possible to achieve this only through sharing the session and filtering the http requests? In other words, if I request http://website.com?component=old_component then we serve the old website, and if http://website.com?component=new_zend_component we serve the framework? in each case the user's rights would be verified through the corresponding session information.
Or is it required the old website be under the framework's controller?
I think you can achieve this using apache/nginx/your server's rewrite rules. But if you have complex url structure it could be tricky.
If you'll go with controller maybe it is good idea to have just one default route for "old_components" and specific routes for new ones. But this is not really good approach since you'll be loading ZF + your old project, this will take longer to process than just using web servers rewrite rules.

How to go about allowing plugins for a custom framework?

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.

PHP - MVC within MVC

I'm learning about MVC frameworks, and I am about to start building a website that will eventually store all of my work. I plan to build a simple blog system using a MVC framework. But then I also want to host my other work within that MVC. For instance, if I have just created a simple todo list app that is also built with an MVC framework, I want to be host that on my portfolio too.
For instance, myportfolio.com will be the main app. myportfolio.com/otherapp will be a piece of work that I would like to host on my portfolio.
Can anybody provide any suggestions as to how this might be achieved, without having to port all models, views and controllers to a single main app?
Just make an exception on how the URL is handled. myportfolio.com/, myportfolio.com/foo, myportfolio.com/bar etc. are all handled by your MVC blogging system, only myportfolio.com/otherapp is handled by your otherapp. This can simply be achieved through RewriteRules in an .htaccess file, but how exactly depends on how exactly your framework works.

PHP framework that can be included in other projects

I have a little specific concern, I hope you can help me, I have to develop an application in PHP that doesn't need to be linked to the exclusive use of its installation and could be used or "included" in other projects of PHP, I mean, to develop a web application (such as generation of a graph according to certain parameters passed) that can be used on different pages created for example in phpBB, Drupal, Dreamweaver or PHP Frameworks like CodeIgniter and Zend.
The best example of what I mean is "Google Charts Tools", you just print in the browser the access to the tool with the parameters and the tool does the rest, and this does not depend on the type of framework with which the home page was created.
In short, I'm looking for a framework or lightweight framework with which I can develop an application that simply could be called in an include() or require() on the destination page and can be used, a framework that can somehow "export" the project or application and could be used on one page without having to reinstall the framework on the target server, even the libraries could be included in the target page so you can run the application.
Was working with Codeigniter and tried to attach to a Joomla page but i couldn't because Codeigniter is linked to the URL of the page and I dont want to use Iframes.
Is there something like that?
First of all; I believe you would need some custimization, as frameworks just aren't build that way. But it isn't impossible. In Kohana for example (also codeigniter, but kohana is more flexible), you can build internal requests with Request::factory($uri). If you can find out a way to bypass direct access to index.php, or build a wrapper after which you can do stuff in the Kohana 'environment' you could do it. I don't have a ready-to-use solution, but if you try something and post the code we might be able to help you out some more!
Sounds to me like you want to write a library or class that can do certain things and which can be reused in other code. You can then build an example application around it, using a framework, which uses this library.
If you start with a whole framework, this often makes it really hard to reuse any part of the code, since the framework has certain assumptions or requirements which may not always be true for other projects. As a general rule: a framework is already a complete standalone application. What you want is something smaller than that.
Of course, you can have a look at a framework like Zend, which is basically just a loose collection of individual classes. Together they form a framework, but each part of it is individually usable. Something like CI is on the other end of the spectrum, much more heavily coupled and interdependent.

Categories