Verano Regional is built on a custom PHP MVC architecture that avoids third-party frameworks. A singleDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/AngelZurita28/VeranoRegional/llms.txt
Use this file to discover all available pages before exploring further.
index.php file acts as the application router, dispatching every request to the correct controller and method using a declarative route map. Controllers extend a shared BaseController that handles authentication, role enforcement, database access, and response helpers — keeping individual controllers focused on business logic.
Directory structure
Routing system
All web requests flow throughindex.php. Routes are declared as two associative arrays — $publicRoutes for unauthenticated access and $protectedRoutes for authenticated users. Each entry maps an action string (passed via ?action=) to a [ControllerClass, methodName] pair.
Match public routes
If the action exists in
$publicRoutes, the router instantiates the controller and calls the method — no session check.Verify authentication
If the action is not public and
$_SESSION['user_email'] is not set, the router renders the login form.Default to dashboard
An authenticated request with no
action parameter is treated as action=dashboard.Match protected routes
If the action exists in
$protectedRoutes, the router calls the method. Role checks happen inside the controller via requireRole().Auto-loading controllers
index.php loads every controller file at startup using a single glob loop — no manual require_once per controller is needed:
controllers/ directory is picked up automatically on the next request.
BaseController pattern
All controllers extendBaseController, which wires up the database connection and provides the shared methods below.
requireRole(array $allowedRoles)
requireRole(array $allowedRoles)
Terminates the request with HTTP 403 if the current user’s
$_SESSION['idUserType'] is not in the allowed list.requirePost(string $redirectAction)
requirePost(string $redirectAction)
Redirects to the given action if the request method is not POST.
render(string $viewPath, array $data)
render(string $viewPath, array $data)
Extracts
$data into local variables and loads the view inside the shared menu layout (views/shared/menu.php).redirect(string $action, array $params)
redirect(string $action, array $params)
Builds an
index.php?action= URL from the action name and optional query parameters, then sends a Location header.redirectWithMessage(string $type, string $text, string $action, array $params)
redirectWithMessage(string $type, string $text, string $action, array $params)
Stores a flash message in
$_SESSION['message'] before redirecting, so the destination view can display a success or error notice.jsonResponse(array $data, int $statusCode)
jsonResponse(array $data, int $statusCode)
Sets the
Content-Type: application/json header, encodes $data, outputs it, and exits. Used for AJAX responses.Session management
After a successful login, the following keys are written to$_SESSION:
| Key | Type | Description |
|---|---|---|
userId | int | Primary key of the authenticated user |
user_email | string | User’s email address — presence indicates an active session |
user_type_description | string | Human-readable role name (e.g., “Alumno”) |
idUserType | int | Numeric role ID used by requireRole() |
userCampusId | int | Campus the user belongs to |
isValid | int | 1 if the account has been validated by a coordinator |
user_email is the canonical session presence check. The router and BaseController both test for isset($_SESSION['user_email']) to decide whether a user is authenticated.Adding a new route
Create or identify the controller method
Add a public method to the relevant controller in
controllers/. If the route requires authentication, extend BaseController and call $this->requireRole() at the start of the method.