Routing wvm

The wvm is a term used for loading of web pages using a 3-logic pattern. Routes can be loaded using in-built php server through ports or through external servers such as xampp or wamp or remote servers. By default, Windows files are all loaded from the windows folder through the use of a standard logic which is one of the 3 logics supported. The default behaviour is that spoova tries to load its routes from the 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:

url > windows(route) -> 404 error page

Setting up a route using frame
All window files are loaded from the 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.

Setup steps
  1. Create a separate Frames directory within the windows directory.
  2. In the Frames directory, add a class file that extends to the root Window class.
  3. Add a route class into the windows/Routes directory page by using the page's entry point name as the class name in the spoova\mi\windows\Routes namespace.
  4. Extend the route file to the frame file created earlier
  5. Lastly, add a __construct() method within the frame file which will control how data is shared
  6. These processes can be shortened by working with available cli commands designed for generating files.
  7. Once these setps are completed, when a user tries to access a page with the name of the route file, the route file will be automatically be called. The benefit of the frame file is that it can serve as a parent class that distributes data to several routes, since multiple routes can be extended to that frame file.
File 1 - Frame file sample (UserFrame.php)
  <?php

    namespace spoova\mi\windows\Frames;
    use Window;

    class Userframe extends Window{

        function data() {

            return ['name' => 'Felix'];

        }

    }

  ?>
                    


Step 3, 4 & 5 above

File 2 - Windows file sample (Home.php)
  <?php

    namespace spoova\mi\windows\Routes;

    use spoova\mi\windows\Frames\UserFrame;

    class Home extend Userframe{

        function __construct() {

            print "This is the homepage";

        }

    }

  ?>
                    


Notice : In the above, we can discover that Frames are extensions of Windows. Since the Res::load() can be applied on windows files, then we can say:

File 2 - Windows file sample (Home.php)
  <?php

    namespace spoova\mi\windows\Routes;

    use spoova\mi\windows\Frames\UserFrame;


    class Home extend Userframe{

        function __construct() {

            self::load( 'index', fn => compile() );

        }

    }

  ?>
                    
In example above:
  1. File 1 UserFrame.php was added into the windows/Frame folder and the UserFrame class was extended to the Window root class.

  2. File 2 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.

  3. The self::load() is equivalent to Res::load() compiler method which loads the index.rex.php template file from the windows/Rex directory