A preserved archive of the Logical Gamers community forums, 2009-2025. The original threads and posts, served read-only. Registration, posting and private messages are gone for good.

PHP Framework

1.5k views · started by GAMEchief ·
#1
PHP Framework
I'm starting a PHP Framework, named after myself. I need some ideas of what all to put on it.
At current, it's minimal, and I'm just setting up the foundation of the framework class itself (not its extensions), but works like this:
include('framework.php');
$fw->load('colors');
$hsl = $fw->colors->rgb2hsl(255, 128, 64); // converts red/green/blue to hue/saturation/lightness
$hsl[2] /= 2; // 0 = hue, 1 = saturation, 2 = lightness; makes the color twice as dark
print_r(hsl2rgb($hsl)); // outputs the darkened RGB value

So, it's mostly going to be:
$fw->load('some_name');
$fw->some_name->functions_of_that_extension();

What extensions should I offer?
As is, I got colors (albeit limited in function ATM; only added the above functions and complementary color calculator and split complementary color calculator), and that's it, since I just started yesterday. Thinking about adding MySQL and a Twitter API, but short on ideas after that.[/2]
#2
What is this framework intended for?
#3
Quick website building.
Using pre-coded extensions. Instead of programming from start of the GD library, you can just
$fw->load('images');
$fw->images->gradient($width, $height, $start, $finish);
And be done.

Which is what most frameworks are for, aren't they? Improved development time.
#4
Ah. I see. I haven't worked on those kind of frameworks, I worked with a cURL wrapper framework, and it was pretty decent, some years ago. I haven't used PHP frameworks for website development, so I wasn't sure what the purpose of your framework was.

I would suggest adding functions to create drop down menus, rounded corners (even though there are new functions in CSS that will allow rounded corners, gradients, glow, shadow, etc. on certain browsers: The creative and technical vents of Scott Schiller).
#5
Hmm. I'm definitely going to be doing a lot of GD library stuff, like gradient generators, as I've started working on that a lot recently. I'll look into HTML generators.
#6
You could also create a Javascript framework for stuff you can't do with PHP.
#7
If I did, I doubt it could compete with jQuery. I'm good with JavaScript, but not nearly as good at the things that require timeouts - like animated expand/collapse, floating menus, and the like. i.e. the things that most people are looking for when using JavaScript frameworks. I'm just good enough to do what I need done at the moment.
My forte seems to be PHP. I love the bugger.
#8
Definately add a mysql class. You want to build in a template framework as well - from my experience, extremely important when developing large websites. Maybe a class that formats/parses text? i.e some features could be.

Smilies -> images.
BBCode -> formatted html.

etc.
#9
Well, of course template systems are nice, but I'm not using this to design my site. Just a quick tool for others to use to do specific tasks. Template systems are a pain in the ass to make accessible to anyone who wants to use them, since templates range so drastically.
I'll def. do a parser system. :)
#10
I finished the gradient maker (excluding diagonal gradients). Does this scream easy-to-use?

$cs->load('images');
$cs->images->gradient(Array(
'direction' => 'horizontal',
'width' => 20,
'height' => 20,
'start' => '#000000',
'finish' => '#ffffff',
'type' => 'gif'
));

direction can be horizontal, vertical, h, or v.
start and finish can be hexadecimal, CSL RGB (255,128,64), or an array of RGB (Array(255, 128, 64)). I couldn't think of any other ways to format a color, except HSL, and IDK how one would tell the difference between HSL and RGB. So, it accepts those things, outputs an image in specified format (type).

I was hesitant to use an array as a parameter, since it's not standard (and complicates the length and opening/closing tags), but I think it has too many parameters that it would be more complicated to memorize the order of parameters, so I simplified it to one. Opinions on that idea?
#11
I don't mean you make templates. But for example you could have a template file:

blah.tp
<h1>My simply website called $settings['name']</h1>
<if $settings['user_location']="America">
Welcome. You are an American citizen!
<else>
Unfortunately our website is only for Americans.
</if>

<br /><br />

<if condition="this">
do this
</else>
do that.
</if>


Which you would parse in to raw html. Would be simple. But something like that is so useful when building websites, not necessarily designing them.
#12
I know you didn't mean designing the templates. I was thinking more along the lines of what constitutes when each template loads and where each section of HTML goes (headers, footers, etc.), but I guess I could leave that to them to code.
#13
what is the point of framework
#14
menlohahay wrote:
what is the point of framework

Pre-made coding so that you can built your websites faster. Instead of having to learn the entire GD library to figure out how to create an image, set its colors, create an algorithm to calculate a gradient, and output it, you can use someone else's work to create it in merely a few lines of easy-to-understand code.
#15
<?php
$Lol = "hi";
$Variable = "Lol";

echo ${$Variable};
?>



A little code you might be interested in if you are looking to make a template system as Arti mentioned.
#16
Yeah, I know of that. I discovered it via a typo, interestingly enough.
echo $$Variable; // hi
#17
GAMEchief wrote:
Yeah, I know of that. I discovered it via a typo, interestingly enough.
echo $$Variable; // hi


:P

Well $$Variable is an improper method from what I understand.

Because it is used to do methods such as.

$Variable = "Lol";
$$Variable = "hi";

echo $Lol; // hi
#18
It probably is non-standard. That's just the way I managed to stumble upon it, since it's easy to typo. The $$var I typo'd just happened to have a value associated with it.
I'll start using ${$var} from now on.

Do you know if $begining{$end} works? e.g.
$beginningtest = 1;
$var = "test";
echo $beginning{$var}; // 1

'cause it doesn't work with $beginning$var, and it would be useful, methinks.
#19
GAMEchief wrote:
It probably is non-standard. That's just the way I managed to stumble upon it, since it's easy to typo. The $$var I typo'd just happened to have a value associated with it.
I'll start using ${$var} from now on.

Do you know if $begining{$end} works? e.g.
$beginningtest = 1;
$var = "test";
echo $beginning{$var}; // 1

'cause it doesn't work with $beginning$var, and it would be useful, methinks.


<?php
$Test = "Variable";
$Test2 = "Lol";
$VariableLol = "hi";

echo ${$Test . $Test2}; // hi
?>


That code worked but,

<?php
$Test = "Variable";
$Test2 = "Lol";
$VariableLol = "hi";

echo $Test{$Test2}; // V
?>


As you can tell the second didn't work :P

<?php
$Test2 = "Lol";
$VariableLol = "hi";

echo $Variable{$Test2}; // Error'd out.
?>


That also failed.


<?php
$Test2 = "Lol";
$VariableLol = "hi";

echo ${"Variable" . $Test2}; // hi
?>


That worked fine also.
#20
Cool thanks. I'll try to remember that. I came across a code before that could have used that last one.
#21
GAMEchief wrote:
Cool thanks. I'll try to remember that. I came across a code before that could have used that last one.


Yeah man no problem. :P