Serving Static Files

The location of where Nox will look for your static files (images, CSS, JavaScript, etc) is configured, by default, in the nox-request.php file by a specific call shown below.

$nox->addStaticDirectory(
    uriStub: "/",
    directoryPath: __DIR__ . "/resources/static",
);

This means that any URIs that start with "/" (which all do) will first check if that URI path is actually a file bath relative to the directoryPath parameter (app/resources/static for default installations).

Additionally, only recognized MIME types will be considered serveable files. Just because a file path is valid and exists does not mean it will not return a 404/not found if you have not registered that file extension as a valid MIME type Nox can understand.

More on Registering File Extensions

Multiple Static Directories

By default, only one static directory check is registered and its registered as the root path of all requests. You can, however, virtually map a URI stub to a separate static directory.

For example, if you want all URIs that start with /backend to check a different static folder than your standard front-end pages, you can adjust the uriStub and change the directoryPath parameters.

$nox->addStaticDirectory(
    uriStub: "/",
    directoryPath: __DIR__ . "/resources/static",
);
$nox->addStaticDirectory(
    uriStub: "/backend",
    directoryPath: __DIR__ . "/resources/admin-statics",
);

These directives and settings would go in the nox-request.php project file before a call to $nox->router->processRequestAsStaticFile() is made.