Seems quite nice and clean but i'd perhaps refactor the ToroApplication constructor. Having to pass an array within an array each time is a little messy. I can see why its done but you can achieve the same thing by using func_get_args.
Those backslashes look clunky. Something as commonly used as a forward slash in a URI shouldn't need to be escaped. Quick fix: use something else as a delimiter, such as #, in line 45. (It should be a character that never occurs in a valid URI on the server side. # is a reasonable choice because the fragment never gets passed to the server.)
It made my introduction to PHP much easier and a hell of a lot more powerful. It just felt right to build a website this way. Easily maintainable as well. Great work!
I've used doctrine a few times, its nice that it does auto-loading by default (helps on load-times), but it does immediately quadruple the codebase of almost all my projects.
<?php
require_once('glue.php');
$urls = array(
'/' => 'index'
);
class index {
function GET() {
echo "Hello, World!";
}
}
glue::stick($urls);
?>
Another example with parameter matching and POST method handling:
<?php
require_once('glue.php');
$urls = array(
'/' => 'index',
'/(?P<number>\d+)' => 'index'
);
class index {
function GET($matches) {
if (array_key_exists('number', $matches)) {
echo "The magic number is: " . $matches['number'];
} else {
echo "You did not enter a number.";
}
}
function POST() {
echo 'The value you entered was ' . $_POST['textbox1'];
}
}
glue::stick($urls);
?>
Let's see how I build my website
require_once 'path/to/F3.php';
F3::route('GET /','home');
function home() {
F3::run();Nice, no? This help me start quickly, iterate rapidly and scale easily when the project gets bigger by dividing and expanding the small parts.
- You chose your own directories structure
- No .htaccess hacking needed.
- Own variables table
- Lot of useful plugins, like a lightweight ORM, Form Handler, Unit Testing, Very flexible Caching
- You decide to use OOP, MVC, procedural programming... or a combination of your choice
- Really lightweight: 50kb