Minimal utility helpers for everyday PHP tasks (object-oriented version)
Status: EXPERIMENTAL
MicrofyClass.php is the object-oriented version of microfyPHP-Lite β a minimalist utility class packed with static helper methods to simplify everyday PHP development.
It brings the same no-bloat, no-dependency philosophy β now in a class-based format β offering tools for request handling, debugging, logging, HTML snippets, database access, and more.
Forget frameworks when all you need is power and speed β Microfy is your coding pocketknife.
- You're tired of repetitive boilerplate like
isset($_GET['x']) ? $_GET['x'] : '' - You want clean, expressive, and testable PHP code
- You work in an OOP environment but donβt want bulky libraries
- You need practical helpers like
Microfy::getVar(),Microfy::pp(),Microfy::dbAll()right away - You value full control with zero magic
- Request Access:
getVar(),postVar(),requestVar()and prefixed variants - Debug Tools:
pp(),pd(),mpp(),mlog(), with optional returns (pdd(),pdr()) - Database: PDO helpers like
dbPdo(),dbAll(),dbExists(), etc. - HTML Snippets:
h(),br(),codePhp(),mark(),a(),b(),ul(),li()and more - Array Utils:
getArray()(formerlygetR()) for safe key lookups - Slugify: Easily generate SEO-safe slugs
- JSON Reader:
jsonf()for simple flat-file configs - List Helpers:
cList(),cStr()for smart numbered headings and counters
Use these to generate clean, semantic HTML in PHP β all methods return strings.
tag(): Low-level generic tag builderhtml_tag(): Alias totag()for semantic groupingpretty_html(): Formats raw HTML for human-friendly display
html_html(),html_head(),html_body()html_header(),html_footer(),html_section(),html_article(),html_nav(),html_aside()
html_div(),html_span(),html_p(),html_blockquote(),html_pre(),html_code()html_h1()βhtml_h6()
html_ul(),html_ol(),html_li()html_dl(): Takes an array of['term' => ..., 'desc' => ...]
html_table(),html_thead(),html_tbody()html_tr(),html_th(),html_td()
html_form(),html_label(),html_input(),html_textarea(),html_select(),html_button()
html_br(),html_hr(),html_img(),html_meta(),html_link()
html_script(),html_style()
If you'd rather use functions like e_p(), e_div(), or e_html_ul() instead of writing echo Microfy::p(...), you can include the optional alias file:
require_once 'microfy_echo_aliases.php';This file defines convenient e_ versions of all output-generating methods in Microfy. For example:
e_p("Hello"); // same as echo Microfy::p("Hello");
e_html_ul(["One", "Two"]); // same as echo Microfy::html_ul([...]);These aliases are safe, optional, and designed for quick prototyping or simplified views.
Only methods that return markup or formatted output get
e_aliases β utilities likeslugify()ornow()are excluded.
Use MicrofyClass.php when:
- You prefer structured, class-based projects but want minimal dependencies
- Youβre building tools, scripts, or APIs and donβt need full frameworks
- You want to keep code readable, consistent, and DRY β especially in shared teams
- You want the best of both worlds: OOP and shortcut-style aliases
Want the simplicity of pp($data) or dbAll(...) in your OOP project?
Just include microfy_aliases.php to use short, procedural-style aliases for all Microfy:: methods β no need to prefix everything manually.
require_once 'MicrofyClass.php';
require_once 'microfy_aliases.php'; // optional
pp(['quick', 'debug']); // works alongside Microfy::pp(...)require_once 'MicrofyClass.php';Microfy::pp($_GET);
$name = Microfy::getVar('name', 'Guest');
$email = Microfy::getArray(['email' => '[email protected]'], 'email', 'none');extract(Microfy::getVarsPrefixed(['path', 'id']));
// Example: $_GET = ['path' => 'demo', 'id' => '42'];
// Results: $get_path = 'demo'; $get_id = '42';$pdo = Microfy::dbPdo('localhost', 'mydb', 'user', 'pass');
$rows = Microfy::dbAll($pdo, "SELECT * FROM users");
Microfy::pp($rows);echo Microfy::now();
$data = Microfy::jsonf('users.json');
echo Microfy::a('example.com', 'Example');
echo Microfy::htmlTable($data);
echo Microfy::htmlTable($data, $class, $id);
Microfy::cList(['apple', 'banana', 'cherry']);Microfy::def('APP_NAME', 'microfy');
Microfy::load('config');Microfy::h(2, 'Welcome');
echo Microfy::b('Bold text');
echo Microfy::slugify('This is a title!');
Microfy::ok(); // JSON responseMicrofy::p('Paragraph text', 'highlight');
Microfy::codephp('<?php echo "Hello"; ?>');
Microfy::ul(['Item 1', 'Item 2']);
Microfy::br();
Microfy::c('Step A');π More Examples
We welcome contributions! See CONTRIBUTING.md for details.
MIT License β Β© 2024β2025 SirCode | This project is not affiliated with or endorsed by the PHP Foundation. Use at your own risk β no warranties, no guarantees, just useful code.
Prefer short global functions like pp(), getVar(), or dbAll()?
π microfyPHP-Lite offers the same features β no classes required.