MilkCore

MilkCore

Table of Contents

Interfaces

AuthContract
Authentication Contract

Classes

AbstractController
Abstract Controller Class
AbstractModel
Abstract Model Class
AbstractObject
Abstract class for object management
AbstractRouter
Abstract Router class for handling basic routing functionality
API
API Routing and Management Class
AutoloadLogger
Logger statico semplificato per l'autoloading
CacheRebuilder
FileAnalyzer
Analyzes individual PHP files to extract classes with correct namespace
LazyAutoloader
Cli
Class for registering functions to be called from the command line
Config
Configuration data management class
MySQLResult
Wrapper per mysqli_result per standardizzare le funzioni di fetch
MySql
MySQL Database Management Class
QueryConverter
QueryConverter - Converte query SQL tra diversi dialetti di database
Query
SQL Query Builder Class
SchemaMysql
Database Schema Management Class
SchemaSqlite
Database Schema Management Class for SQLite
SQLiteResult
Wrapper per SQLite3Result che converte i metodi in snake_case per consistenza con lo stile del framework
SQLite
SQLite Database Management Class
File
Static file handling class with mandatory file locking
Form
Bootstrap-styled form generator with support for various input types and validation.
Get
Facade Class for Core System Functionality
Hooks
Hook management system that allows registering one or more functions to be called later
HttpClient
Simple and versatile static HTTP client based on cURL
Lang
Internationalization and Localization Class
Logs
Logging System Class
Mail
Wrapper for PHPMailer class
MessagesHandler
Message Handling System
ListStructure
La classe ListStructure gestisce la struttura delle colonne di una tabella Implementa ArrayAccess per poter accedere alle proprietà come array
ModelList
page: modellist.class.php La classe ModelList aiuta a gestisce la visualizzazione delle tabelle html a partire da una tabella mysql
PageInfo
La classe PageInfo gestisce le informazioni di pagina per la tabella Implementa ArrayAccess per poter accedere alle proprietà come array
ObjectToForm
Form Generator from Object Definitions
Permissions
Permission Management System
Route
Page Routing and URL Management Class
Sanitize
Data Sanitization Class
Settings
Settings Class - A flexible configuration management system
Theme
GP Theme Template-specific data storage class.
Token
Generates a token that can be used to authenticate a user and protect forms from CSRF attacks.

Constants

BASE_URL  = \MilkCore\Route::url()
Base URL of the application
NEW_VERSION  = '250609'
Version identifier in format AAmmXX (YearMonth + sequence)
STORAGE_DIR  = realpath(MILK_DIR . '/' . \MilkCore\Config::get('storage_dir', 'storage'))
Directory of the storage
THEME_DIR  = realpath(MILK_DIR . '/' . \MilkCore\Config::get('theme_dir', 'theme'))
Directory of the theme
THEME_URL  = \MilkCore\Route::url() . "/" . (\MilkCore\Config::get('theme_dir') ?? 'theme')
URL to the theme directory

Functions

_r()  : string
Sanitizes and returns a string value
_rt()  : string
Returns sanitized and translated string
_rh()  : string
Returns HTML-escaped string
_raz()  : mixed
Esegue un preg_replace per eliminare i caratteri speciali Aggiunge un carattere se il primo è un numero
_p()  : void
Outputs a sanitized string
_pt()  : void
Outputs a translated and sanitized string
_ph()  : void
Outputs an HTML-escaped string
_pjs()  : void
Outputs a value as a JavaScript literal
_paz()  : string
Sanitizes a string for use in HTML IDs, classes, or other identifiers
_absint()  : int
Sanitizes and returns a positive integer
get_val()  : mixed
Retrieves a value from an object or array with fallback support
to_mysql_array()  : array<string|int, mixed>
Converts an object or array of data into a format suitable for MySQL

Constants

BASE_URL

Base URL of the application

public mixed BASE_URL = \MilkCore\Route::url()
Tags
global

string BASE_URL

NEW_VERSION

Version identifier in format AAmmXX (YearMonth + sequence)

public mixed NEW_VERSION = '250609'
Tags
global

string NEW_VERSION

STORAGE_DIR

Directory of the storage

public mixed STORAGE_DIR = realpath(MILK_DIR . '/' . \MilkCore\Config::get('storage_dir', 'storage'))
Tags
global

string STORAGE_DIR

THEME_DIR

Directory of the theme

public mixed THEME_DIR = realpath(MILK_DIR . '/' . \MilkCore\Config::get('theme_dir', 'theme'))
Tags
global

string THEME_DIR

THEME_URL

URL to the theme directory

public mixed THEME_URL = \MilkCore\Route::url() . "/" . (\MilkCore\Config::get('theme_dir') ?? 'theme')
Tags
global

string THEME_URL

Functions

_r()

Sanitizes and returns a string value

_r(mixed $var) : string

This function is used to safely handle user input by escaping special characters. It's suitable for general string sanitization when the output context is plain text.

Parameters
$var : mixed

The variable to sanitize

Return values
string

The sanitized string, or empty string if input is not scalar

_rt()

Returns sanitized and translated string

_rt(mixed $var) : string

This function first translates the string using the current language settings and then sanitizes it for safe output. It's ideal for user-facing text that needs to support multiple languages.

Parameters
$var : mixed

The string to translate and sanitize

Return values
string

The translated and sanitized string, or empty string if input is not scalar

_rh()

Returns HTML-escaped string

_rh(mixed $var) : string

Use this function when you need to output content within HTML. It converts special characters to HTML entities to prevent XSS attacks.

Parameters
$var : mixed

The string to escape

Return values
string

The HTML-escaped string, or empty string if input is not scalar

_raz()

Esegue un preg_replace per eliminare i caratteri speciali Aggiunge un carattere se il primo è un numero

_raz(mixed $var) : mixed
Parameters
$var : mixed

_p()

Outputs a sanitized string

_p(mixed $var) : void

This function is a convenience wrapper that sanitizes and immediately outputs a string. It's equivalent to echo _r($var) but more concise.

Parameters
$var : mixed

The string to sanitize and output

_pt()

Outputs a translated and sanitized string

_pt(mixed $var) : void

This function combines translation and sanitization for output. It's commonly used for user interface text that needs to be both translated and safe to display.

Parameters
$var : mixed

The string to translate and output

_ph()

Outputs an HTML-escaped string

_ph(mixed $var) : void

Use this function when you need to output content directly within HTML. It's a shortcut for echo _rh($var).

Parameters
$var : mixed

The string to escape and output

_pjs()

Outputs a value as a JavaScript literal

_pjs(mixed $var) : void

This function safely outputs values within JavaScript code blocks by using json_encode() to properly escape the content. It handles all JavaScript data types including strings, numbers, arrays, and objects.

Parameters
$var : mixed

The value to output as JavaScript

Tags
example
<script> var userName = ; var userData = ; </script>

_paz()

Sanitizes a string for use in HTML IDs, classes, or other identifiers

_paz(string $var) : string

This function removes all non-alphanumeric characters and ensures the result starts with a letter. It's useful for creating safe HTML identifiers from user input.

Parameters
$var : string

The string to sanitize

Return values
string

The sanitized string with only alphanumeric characters and underscores, starting with a letter

_absint()

Sanitizes and returns a positive integer

_absint(mixed $var) : int

This function ensures the returned value is always a non-negative integer. It's particularly useful for sanitizing IDs, counts, and other numeric values that should never be negative.

Parameters
$var : mixed

The value to sanitize

Return values
int

The sanitized positive integer, or 0 if conversion fails

get_val()

Retrieves a value from an object or array with fallback support

get_val(object|array<string|int, mixed> $class, string $property) : mixed

This helper function provides a consistent way to access values from different data structures, including objects with magic getters or custom get_value methods. It's particularly useful for working with model objects that might implement custom value retrieval logic.

Parameters
$class : object|array<string|int, mixed>

The object or array to get the value from

$property : string

The property name or array key to retrieve

Tags
example

// Works with arrays $data = ['name' => 'John']; $name = get_val($data, 'name'); // Returns 'John'

// Works with objects $user = new User(); // Assuming User has a 'name' property $name = get_val($user, 'name');

// Falls back to get_value() method if it exists $value = get_val($someObject, 'custom_property');

Return values
mixed

The value of the property, or null if not found

to_mysql_array()

Converts an object or array of data into a format suitable for MySQL

to_mysql_array(mixed $obj[, array<string|int, mixed> $default_data = [] ]) : array<string|int, mixed>

This function handles conversion of various data structures (objects, arrays, models) into a format that can be used with MySQL queries. It supports model objects with a to_mysql_array() method and falls back to default data when needed.

Parameters
$obj : mixed

The data to convert (model object, stdClass, or array)

$default_data : array<string|int, mixed> = []

Default data to use as a base (typically $_REQUEST or $_POST)

Tags
example

// With a model object $user = new User($id); $data = to_mysql_array($user, $_POST);

// With a regular array $data = to_mysql_array(['name' => 'John', 'age' => 30]);

Return values
array<string|int, mixed>

The converted data ready for MySQL operations


        
On this page

Search results