darling/roady-ui-utilities

UI utilities for the Roady php framework.

v1.0.0 2024-02-27 21:49 UTC

This package is auto-updated.

Last update: 2024-10-27 23:07:23 UTC


README

Provides classes for the Roady php framework's User Interface.

Installation

composer require darling/roady-ui-utilities

Classes

\Darling\RoadyUIUtilities\classes\ui\html\UserInterface

A UserInterface can render output for a Response.

The UserInterface's defined under the Darling\RoadyUIUtilities\interfaces\ui\html namespace are intended to produce html for a web page based on the Routes defined by a given Response.

The following is a snippet from the Roady php framework's index.php file showing how a UserInterface is used in practice.

$currentRequest = new RequestInstance();
$roadyModuleFileSystemPathDeterminator =
    new RoadyModuleFileSystemPathDeterminatorInstance();

$router = new RouterInstance(
    new ListingOfDirectoryOfRoadyModulesInstance(
        RoadyAPI::pathToDirectoryOfRoadyModules()
    ),
    new ModuleCSSRouteDeterminatorInstance(),
    new ModuleJSRouteDeterminatorInstance(),
    new ModuleOutputRouteDeterminatorInstance(),
    $roadyModuleFileSystemPathDeterminator,
    new ModuleRoutesJsonConfigurationReaderInstance(),
);

$response = $router->handleRequest($currentRequest);

$roadyUI = new UserInterface(
    RoadyAPI::pathToDirectoryOfRoadyModules(),
    new RouteCollectionSorterInstance(),
    $roadyModuleFileSystemPathDeterminator,
);

echo $roadyUI->render($response);