All server-side configuration for the ISBO Equipment Registry lives in a single file:Documentation Index
Fetch the complete documentation index at: https://mintlify.com/gavafue/registroComponentesMultimedia/llms.txt
Use this file to discover all available pages before exploring further.
api/config.php. This file is included at the top of every PHP endpoint (auth.php and loans.php) via require_once. It handles three responsibilities: creating and setting a local PHP session directory, opening the PDO database connection, and defining the sendJsonResponse() helper used by every endpoint to return JSON.
The api/config.php file
Below is the full file with the real password replaced by a placeholder:Connection variables
| Variable | Default value | Description |
|---|---|---|
$host | localhost | Hostname or IP of your MySQL server. Change to 127.0.0.1 or a remote host if MySQL runs on a separate machine. |
$db_name | isbo_prestamos | Name of the database. Must match the database you created during installation. |
$username | root | MySQL user account. On production servers, create a dedicated user with only SELECT, INSERT, UPDATE, and DELETE privileges on isbo_prestamos rather than using root. |
$password | (your password) | Password for the MySQL user above. |
PDO connection attributes
After a successful connection, two PDO attributes are set:PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION— any SQL error throws aPDOException, which is caught in each endpoint and returned as a JSON error response with HTTP 500.PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC— query results are returned as associative arrays (column name as key), so the JSON output uses column names directly as property names.
error key, then halts — no endpoint logic runs.
Session path: api/sesiones/
The application deliberately avoids storing PHP sessions in the system’s default temporary directory. Instead,config.php stores sessions inside the project itself:
- Portability — moving the project folder to a different server or user account keeps sessions working without reconfiguring
php.ini. - Predictability on shared hosts — some shared hosts restrict writes to the system
/tmpdirectory; a project-local directory bypasses that restriction.
The
mkdir($sessionPath, 0777, true) call only runs if the directory does not already exist. On first request the directory is created automatically, so you do not need to create it manually during deployment.api/sesiones/ directory should not be web-accessible. If your Apache configuration serves everything under api/, consider adding a .htaccess file in api/sesiones/ to deny direct access:
The sendJsonResponse() helper
Every API endpoint returns JSON throughsendJsonResponse():
- Sets the HTTP response code (defaults to
200; endpoints pass400,401,404, or500for errors). - Sets the
Content-Type: application/jsonheader so browsers and thefetch()client parse the body correctly. - Calls
exitimmediately afterjson_encode()to ensure no additional output follows — stray whitespace or PHP notices would corrupt the JSON.
API.request() method in assets/js/api.js always calls response.json() on the response, so all endpoints must return valid JSON — including error responses.
Changing the admin password
To update an existing admin user’s password, generate a new bcrypt hash with the PHP CLI and run anUPDATE query:
The API_BASE constant in assets/js/api.js
The JavaScript fetch wrapper resolves all API URLs relative to a single constant at the top ofassets/js/api.js:
index.html is served from the project root (e.g. http://localhost/registroComponentesMultimedia/index.html). If you install the application in a subdirectory or configure Apache to serve it from a non-root virtual host path, you must update API_BASE to reflect the path to the api/ folder as seen by the browser.
For example, if the app is accessible at https://example.com/sistemas/registro/:
API_BASE affects every API call in the application — login, checkout, return, stats, history, and PDF export all use it. Change it in one place and all requests update automatically.