Jump to content

idea's for framework


Ninjakreborn

Recommended Posts

I have rewritten a huge skeleton for a framework. My own personal portable framework I am reusing in all my projects.
Some of the first few functions I came up with I intended to deal with some issue's i was running across.  I find myself fiddling with php.ini sometimes.  So I wrote some functions to deal with these, I was wanting to get some advice on these, or ideas on increasing functionality of these functions.  Or if someone thinks these are faulty what they would suggest.

THe first takes a number.  When the number is taken, it put's it into the case switch statement.

when I first start up it defaults at
error(5);
so I can see all errors
then when I am done, I change it to error(0) which automatically set's it all back to the securest settings.

The second function is what I use with databasing.
I get tired of cutting off magic quote's, and I alway's like working with that off, so I can do it myself, I had issue's with it in the page, so with this, I end up having it do just that.
When I pass
inisettings("safe");
it turns off the magic quotes, and make's sure that register globals is off, it start's off at that value
if for some reason I needed the register global's on for a 3rd party(don't normally use them), then I can just pass inisettings("no");
well tehcnically there's no point for the other so I will probably take that off later.  But for now, this is the general idea
[code]
<?php
// The following function set's the level of error display. 
function error($elevel) {
switch ($elevel) {
case 0:
error_reporting(0); // off
ini_set('display_errors', 'Off');
    ini_set('log_errors', 'On');
case 1:
error_reporting(E_ERROR | E_WARNING | E_PARSE); // simple running errors
case 2:
error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE); // most errors
case 3:
error_reporting(E_ALL ^ E_NOTICE); // all except notice, php.ini default
case 4:
error_reporting(E_ALL); // all errors
case 5:
error_reporting(E_ALL | 'E_STRICT'); // all with strict
}
}
// This can be set to safe or not, safe makes the safest php.ini settings
// not, does not.
function inisettings($inisettings) {
switch ($inisettings) {
case "safe":
ini_set("magic_quotes_gpc", 0);
ini_set("register_globals", 0);
case "not":
ini_set("register_globals", 1);
}
}
?>
[/code]
Link to comment
Share on other sites

i'm not sure of your question here, if there is one.

however, i'd suggest that a function that turns register_globals on or off is a waste of time - mainly because you should always code without needing it on, and because it's gonna be disappearing with the next version of php anyway. same goes for magic quotes - the problem with having a function that turns it on or off is that you'll wind up coding different projects in different ways depending on whether you 'decide' to have it on or not. keeping coding consistency will help you expand the project in the future when you come back to it.

i never personally touch the php.ini file after one initial setup. turning display_errors off, register_globals off, magic_quotes_runtime, etc, all off. the only thing i EVER need to change in terms of PHP settings is error_reporting/display_errors/display_startup_errors all go on, but i always do these in a htaccess file so that if i move my project to a different server (which is 99% the case when developing for a client on your machine before putting it on theirs) - that way, i dont need to remember what settings in my PHP.ini file i need to set on a clients server.
also, using ini_set for errors doesnt really work for me. in the event, for example, i get a file that has a parse error - missing bracket, etc. as this means the file wont be parsed at all, neither will the ini_set line - meaning you're gonna be facing a blank page facing the mundane task of debugging your code.

seriously, if you can't beat 'em, join 'em - i've mentioned it before, but i chose the [url=http://www.codeigniter.com]CodeIgniter[/url] framework to model my own framework on, because its very simple, mostly well written, and (with a few slight changes to the structure) very easy to build around, with a plugin architecture so that things only get included if they're required by certain scripts. also based on the MVC pattern (which i dont know what i was ever doing without it) and tidy URL's. i have a single copy of my framework on my server, and so far i have about 3 development sites that are using it already. and adding extra functionality just requires me digging into its code, making some changes, without worrying about breaking a thing. seriously, take a look at it - even if just for educational purposes. you'll pretty soon realise that incorporating your own custom error handling routines, debugging scripts, logging scripts, etc, is as easy as pie and far outweighs mucking around with settings all the time.

cheers
Mark
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.