window/Routes directory which is equivalent to the spoova\mi\windows\Routes namespace.
If the route file does not exist spoova will return a 404 error response which can be in form of a 404 error page or 404 json response. The behavior is shown below:
windows directory while routes are loaded from windows/Routes directory. Route files
can be extended to root Window class or Frames. Frames are binding structures that can be used as a parent group for different Routes.
Their functions are to define basic structure or concepts a route
can emulate. For example, Frame files can be used to separate or divide sessions which are
only recognized in some particular windows files. Hence, all window files extending to such
Frames will only derive their session values from their parent frame file. Proceedures below
helps to explain the steps or stages involved in setting up a new route.
Frames directory within the windows directory.Frames directory, add a class file that extends to the root Window class.windows/Routes directory page by using the page's entry point name as the class name in the spoova\mi\windows\Routes namespace.__construct() method within the frame file which will control how data is shared
<?php
namespace spoova\mi\windows\Frames;
use Window;
class Userframe extends Window{
function data() {
return ['name' => 'Felix'];
}
}
?>
<?php
namespace spoova\mi\windows\Routes;
use spoova\mi\windows\Frames\UserFrame;
class Home extend Userframe{
function __construct() {
print "This is the homepage";
}
}
?>
Res::load() can be applied on windows files, then we can say:
<?php
namespace spoova\mi\windows\Routes;
use spoova\mi\windows\Frames\UserFrame;
class Home extend Userframe{
function __construct() {
self::load( 'index', fn => compile() );
}
}
?>
UserFrame.php was added into the windows/Frame folder
and the UserFrame class was extended to the Window root class.
Home.php which exists in the windows/Routes directory is expected to be
instance of the in-built Window object so as to become a route. Since the UserFrame.php extends to the root
Window class, the Home.php can inherit the properties of a window from the UserFrame
class it was extended to.
self::load() is equivalent to Res::load() compiler method which loads the
index.rex.php template file from the windows/Rex directory