views:

84

answers:

2

We have a really old legacy code base that uses globals like they're going out of fashion - nearly all of the inter-page communication is done via globals and sessions or both. This could be changed as a last resort but ideally I don't want to touch any of it as everything I touch could introduce more bugs :-p.

Anyway, We're incorporating a new "module" into the application which was written completely in zend and is really nice and modular. My aim is to get zend running as the backbone and the old legacy code to run as a sort of module/controller within zend and once it has control just execute normally and do whatever it wants.

The 2 issues I have:

  • I need to get Zend to see that I'm using legacy URL's (login.php, show.php, etc) and pass execution to a specific controller;

  • I'm embedding an entire application inside a function of another and this breaks the default behavuour of variables appearing in the global scope as globals - i.e. they're now just local variables of this method and thus can't be seen without first specifying that they are globals.

If there's another way this could be done I'd be happy to hear it :-p

Cheers,
Chris

+2  A: 

For the first issue I think you can use the Zend_Router class.

But nevertheles I dont think is a good idea to port a procedural application to the ZF concept which is a object oriented one.

I would either rewrite the application or just use separate classes as loose components, thing that is recommended by ZF creators as well.

Elzo Valugi
Yeah; I'm not really porting the app - I just need ZF to do a little work to determine which module to load and if that happens to be a legacy module then it just hands over and forgets zend was ever involved. If it's a normal module it gets all the benefits of zend.
widgisoft
A: 

Turns out I was being way too ambitious;

I realised the new "module" was mostly just JavaScript and a little PHP controller (CRUD) backed up by a mass of ZF and all I really wanted was to port was the JS front end - no one actually cares how the back end is implemented.

I decided to simply transplant the JS front end and just provide a similar interfaces as before and now don't need to worry about Zend and just code in some alternate functionality in the legacy app.

Yay.

Strangely I realised this while putting sugar in my cup while making a cup of tea; Instead of moving the spoon over to the cup (from the sugar jar and spilling it everywhere (i.e. lots of code to re-write)) move them both over the cup and remove the sugar jar from underneath - you get the same result with less mess, the sugar was the JS and the Jar was the big ZF framework :-p

widgisoft
:) thanks for sharing the experience
Elzo Valugi