I am considering to use a php framework (never used one before), I know I have to abandon the way I am used to work (I can deal with this), among many concerns a first thing that comes in my mind is this:
I have two techniques I like to use (have used them for years)..
I always use index.php?somePage.php as href so never loads another page other that index.php, then index.php includes the somePage.php
I always used to store all texts, any text, titles, button names, link names, stories, articles, anything, in a single (or more) files or in GLOBALS array (depending on size).
I want to ask is this aproach wrong, is there any better way?
Second, from what I have read freamworks have some rules, does my approach create some conflict? I am thinking of KISS_MVC framework cause it declares to be easy for framework beginers.
I have no experience with frameworks and I am concerned, about all this, I can't wait for the day I will feel like home with using a framework.
Thank you all in advance!
That pattern is known as front controller - it gets all requests and routes them internally (not based on file loaded). That pattern is fine, it should look like /index.php/whatever
to which you can then patch over with .htaccess
to make /whatever
(Examine $_SERVER['REQUEST_URI']
).
Database is a good place to store large amounts of text. Files you create rarely are - they offer none of the advantages of using a database. $GLOBALS
rarely is a good place to store data. You generally should keep as little as possible available globally. You can make a registry class to store global stuff if you need.
The best way to know what does and doesn't work with a framework is to try and get familiar with a popular one such as Zend, Kohana, Yii, etc.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.