From 7877bf33ce0d77f494711787ecc378327e2634cb Mon Sep 17 00:00:00 2001 From: shoully Date: Sat, 20 Dec 2014 05:58:20 -0800 Subject: [PATCH] Created Overriding (markdown) --- Overriding.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 Overriding.md diff --git a/Overriding.md b/Overriding.md new file mode 100644 index 0000000..a6242f5 --- /dev/null +++ b/Overriding.md @@ -0,0 +1,20 @@ +Flight allows you to override its default functionality to suit your own needs, without having to modify any code. + +For example, when Flight cannot match a URL to a route, it invokes the `notFound` method which sends a generic HTTP 404 response. +You can override this behavior by using the `map` method: + + Flight::map('notFound', function(){ + // Display custom 404 page + include 'errors/404.html'; + }); + +Flight also allows you to replace core components of the framework. +For example you can replace the default Router class with your own custom class: + + // Register your custom class + Flight::register('router', 'MyRouter'); + + // When Flight loads the Router instance, it will load your class + $myrouter = Flight::router(); + +Framework methods like `map` and `register` however cannot be overridden. You will get an error if you try to do so. \ No newline at end of file