-
Notifications
You must be signed in to change notification settings - Fork 173
Changelog
anandkunal edited this page Aug 18, 2012
·
7 revisions
Toro v2.0.0 is a significant departure from v1.0.0. As the API is not backwards-compatible, please review the changes below.
The old API:
<?php
class MainHandler extends ToroHandler {
function get() {
echo "Hello, world";
}
}
$site = new ToroApplication(array(
array("/", "MainHandler")
));
$site->serve();
The new API:
<?php
class MainHandler {
function get() {
echo "Hello, world";
}
}
Toro::serve(array(
"/" => "MainHandler"
));
Several things to note from the changes:
-
ToroApplication
has been replaced withToro
, a static class - Calling
serve
now requires a simplified associative array of routes (route => handler) -
ToroHandler
has been removed (empty and unnecessary class)
Routing has been significantly improved. As of v2.0.0, you can define routes like:
<?php
Toro::serve(Array(
"/catalog" => "CatalogHandler",
"/catalog/page/:number" => "CatalogHandler",
"/product/:alpha" => "ProductHandler",
"/manufacturer/:string" => "ManufacturerHandler"
));
With v2.0.0, you can now use route stubs such as :number
, :string
, and :alpha
(alphanumeric). These are expanded at matchtime via string replacements.
Note, you can still use regular expressions. Here's the same example above using regexes instead of route stubs:
<?php
Toro::serve(Array(
"/catalog" => "CatalogHandler",
"/catalog/page/([0-9]+)" => "CatalogHandler",
"/product/([a-zA-Z0-9-_]+)" => "ProductHandler",
"/manufacturer/([a-zA-Z]+)" => "ManufacturerHandler"
));
404 management has been extracted from toro.php
and is now managed by a special 404
ToroHook:
<?php
ToroHook::add("404", function() {
header("HTTP/1.0 404 Not Found");
echo "Missing Page";
exit;
});
This gives you control over specifying the header, including a page, exiting the control flow, etc.
- Adjusted cache busting headers for
xhr
requests - Removed overrides from routes (use default method arguments instead)
- Removed specialized mobile and tablet methods (use responsive layouts instead)
- Removed the unused
InvalidRouteType
exception
- Revised the projects's readme to reflect the new API
- Updated existing examples to use the new API
- Created the changelog to handle future updates
- Added an MIT License
- Added a .gitignore to prevent .DS_Store jank
- Initial release