Jump to content

PHP application structure


sasori

Recommended Posts

Hello,

 

I built a system using a framework called Yii, now I was asked to re-write everything from scratch without a framework. I don't know how to do a system architecture, I'm used to do coding rightaway controllers,models with the help of an existing php framework w/o minding system design/folder structures., can you guys give me some tips how to do such? or a templating engine such as smarty can do the job for me ?

 

Thanks in advance.

Link to comment
Share on other sites

Why were you asked to re-write it without a framework?  I would just go ahead and copy the framework's structure.  Smarty is just a templating engine, not a framework or a structure, although it can form part of one.

 

Honestly the best approach is to find a framework you like and use that, but if you were specifically asked not to use an existing framework, then I would instead find a framework you like and copy how it works.

 

The structure we use is more or less MVC, with a small controller sending requests off to various files that implement a particular page, and they send requests off to classes that do most of the work.  Those pages then return an array to smarty which renders the template.

Link to comment
Share on other sites

because a 3rd party module made up of spaghetti and some oop coding style will be integrated in the system and i think it'll cause a huge impact in most of my code or if not, i will have to tweak the third party stuff to fin in the framework that i use..that's why they asked me to re-write everything without a framework..they worry about having a limitation of hiring someone who doesn't know the framework that i use..

Link to comment
Share on other sites

Learning a framework is easier than sifting through someone else's code :/

 

Do they plan to hire someone capable of building a framework but can't use one?!

 

I already explained that the other devs they have are cool and better than me and they can learn the framework that I use in a short period of time..

but , you know, am not the boss so I lost the debate battle

Link to comment
Share on other sites

Fair enough.. if your boss asks you to re-invent the wheel then you have to re-invent the wheel.  And the best way is to look at an existing wheel and more or less copy it.  Googling "PHP MVC tutorial" turns up quite a number of tutorials, so that's another possible angle to start with.

 

I'm a bit reluctant to give advice at this stage - I would find it much easier if you started writing the framework and posted back here when you got stuck.

 

One tip - if you're going to be integrating with 3rd party spaghetti code, I would seriously consider using namespaces to insulate your code from the spaghetti.  Unless the spaghetti happens to have clearly defined boundaries in how it deals with the global namespace.

Link to comment
Share on other sites

Fair enough.. if your boss asks you to re-invent the wheel then you have to re-invent the wheel.  And the best way is to look at an existing wheel and more or less copy it.  Googling "PHP MVC tutorial" turns up quite a number of tutorials, so that's another possible angle to start with.

 

I'm a bit reluctant to give advice at this stage - I would find it much easier if you started writing the framework and posted back here when you got stuck.

 

One tip - if you're going to be integrating with 3rd party spaghetti code, I would seriously consider using namespaces to insulate your code from the spaghetti.  Unless the spaghetti happens to have clearly defined boundaries in how it deals with the global namespace.

 

I see, php5.3 namespaces..thanks for the extra tips :D

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.