Virtual root

By default, all requests from users for an executable file (*.php) or folder are processed by the framework (Engine class) as follows: for each file listed below, for each virtual root from first to last searching for the specified files:

  1. directly requested php-file or file index.php in requested folder
  2. file .router.php up the directory hierarchy relative the query

As soon as the first file is found, it executes it, interrupting further search.
All active virtual roots must be registered in the config (key 'roots').

Example

Suppose we have two virtual roots /site/root and /core/root :

User request Searching for a corresponding entity
/feedback.php
  • /site/root/feedback.php
  • /core/root/feedback.php
  • /site/root/.router.php
  • /core/root/.router.php
  • /admin/
  • /site/root/admin/index.php
  • /core/root/admin/index.php
  • /site/root/admin/.router.php
  • /core/root/admin/.router.php
  • /site/root/.router.php
  • /core/root/.router.php
  • Following this logic, you can redefine any file in the framework’s virtual root by creating file in its virtual root along a similar relative path.

    If no file is found, the Engine searches for the redirect or content from the database (entities Redirects and Content),
    if nothing has been found - it throws an exception ExceptionPageNotFound, which is subsequently processed in the Show404 method.

    Access to sections (folders)

    Framework allows to override template and wrapper for each section, as well as to restrict\allow access to the section and all subsections for specific user groups. To do this, you need to create a file .section.php in the root of the section and return the associative array in it, describing section (all keys are optional):

    Example

    <?php
    return [
    	'TEMPLATE' => 'admin',
    	'ACCESS'   => [
    		'*'    => false,
    		'root' => true,
    	],
    ];
    

    • * — pseudo code for any user (includes unauthorized)
    • @ — pseudo code for authorized user
    • root — code of user group 'Root'

    For more complex access restriction logic, use exceptions in your own code.

    Template and wrapper

    When the request is completed, the engine wraps the result in a wrapper of template, if necessary.

    Ask question