Micro utility functions for everyday PHP tasks. Minimal helpers for maximum flow
microfy.php
is a lightweight collection of procedural PHP helper functions designed to speed up development and simplify common patterns like superglobal access, debugging, logging, array handling, UI snippets, and database access.
Forget bloated frameworks β microfy.php
gives you practical tools with no setup, no classes, no magic.
$_GET
, $_POST
, debug dumps, and simple logs.get()
, post()
, request()
, plus extract helperspp()
, pd()
, d()
, log_pr()
, log_vd()
, mlog()
jsonf()
for quick file-based config/datah()
, br()
, hr()
, mark()
, code()
, a()
, etc.get_r()
for safe accessdb_pdo()
, db_all()
, db_exists()
β simple and safec_str()
, c_list()
for numbered docs or stepsUse microfy.php
when you:
$path = get("path"); // default is ""
$lang = get("lang", "default"); // explicit default
Result from URL /?path=...extract(get_all([
'get_path' => ['path'], // default is ''
'get_file' => ['f'], // also allowed
'emlFile' => ['emlFile', 'default'] // explicit default
]));
extract(get_vars(['path', 'f', 'emlFile']));
extract(get_vars(['path', 'f', 'emlFile'], 'get_'));
$lang = get("lang", "default"); echo $lang;
Result from URL /?lang=...$path = post("path"); // default is ""
$lang = post("lang", "default"); // explicit default
Result from URL /?path=...extract(post_all([
'post_path' => ['path'], // default is ''
'post_file' => ['f'], // also allowed
'emlFile' => ['emlFile', 'default'] // explicit default
]));
extract(post_vars(['path', 'f', 'emlFile']));
$id = request("id", "none"); echo $id;
Result (GET or POST):$array = ['name' => 'Alice', 'email' => 'alice@example.com'];
pp($array);
Result:Array ( [name] => Alice [email] => alice@example.com )
echo get_r($array, "name");
$array = ['fruit' => 'apple', 'color' => 'red'];
pp($array);
Array ( [fruit] => apple [color] => red )
ppd($array);
mpp('Label 1', $array1, $array2);
pd($array, 'Labeled Dump');
Labeled Dump: array(2) { ["fruit"]=> string(5) "apple" ["color"]=> string(3) "red" }
pdd($array, 'Dump + Die');
d('dump label', $array, $config);
dd($user, $session);
$testArray = ['name' => 'Alice', 'age' => 30];
log_pr($testArray, 'User Data');
log_vd($testArray, 'User Data Dump');
mlog("Something happened", "Note", "custom.log");
slugify("Hello World! Clean URL");
$data = jsonf("demo_data.json");
Result:Array ( [title] => Sample JSON [items] => Array ( [0] => one [1] => two [2] => three ) )
ul(["One", "Two"], "my-list");
Result:echo a('example.com');
// <a href="https://example.com">https://example.com</a>
echo a('example.com', 'Visit');
// <a href="https://example.com">Visit</a>
echo a('example.com', 'Visit', '_blank');
// <a href="https://example.com" target="_blank">Visit</a>
echo a('example.com', 'Visit', '_blank', 'btn btn-primary');
// <a href="https://example.com" target="_blank" class="btn btn-primary">Visit</a>
span('Visit our ' . a('docs.example.com', 'documentation'));
// <span>Visit our <a href="https://docs.example.com">documentation</a></span>
html_table($array);
id | username | |
---|---|---|
1 | alice | alice@example.com |
2 | bob | bob@example.com |
3 | carol | carol@example.com |
$pdo = db_pdo("localhost", "your_db", "your_user", "your_pass");
$stmt = $pdo->query("SELECT * FROM users");
$data = $stmt->fetchAll(PDO::FETCH_ASSOC);
pp($data);
foreach ($data as $row) {
echo $row["id"] . " | ";
}
Array ( [0] => Array ( [id] => 1 [username] => alice ) [1] => Array ( [id] => 2 [username] => bob ) )1 | 2 |
$all = db_all($pdo, "SELECT * FROM users");
$usernames = array_column($all, "username");
ul($usernames);
$all = db_all($pdo, "SELECT * FROM users");
// Format each row as a string
$items = array_map(function ($row) {
return "{$row['id']}, {$row['username']}, {$row['email']}";
}, $all);
// Output as unordered list
ul($items);
$all = db_all($pdo, "SELECT * FROM users");
html_table($all);
id | username | |
---|---|---|
1 | alice | alice@example.com |
2 | bob | bob@example.com |
3 | carol | carol@example.com |
$email = "someone@example.com";
if (db_exists($pdo, "users", "email", $email)) {
echo "User exists!";
}
Result:h(2, "Some h2 Title");
Result:
bra(i("Result:")); br("First line"); hr("Part A", "Part B");
Result:echo b('Bold text', 'highlight');
echo i('Italic text', 'italic-grey');
echo small('Note', 'dim');
echo mark('Hot!', 'warning');
echo bi('Bold + Italic', 'combo');
echo b('Bold'); echo i('Italic'); echo bi('Bold Italic');
Bold Italic Bold Italicecho mark('Highlighted'); echo small('Fine print');
Marked Fine printecho mark(bi('Hello!'));
Hello!p('This is a paragraph.', 'info-text');
This is a paragraph.
span(mark(b('Inline Highlight')));
Inline Highlightspan(b('Inline Class'), 'myhighlight';
Inline Classsection(bi('Section title') . '<br>' . small('Details...'), 'section-box');
c_st('First')
c_st('Second')
c_st('Second')
c_list(['Step A', 'Step B', 'Step C']);
c_list(['One', 'Two'], true); // resets numbering
1. Step Acode($php_code, 'php');
<?php echo "Hello world!"; ?>
const name = "Alice";
console.log("Hello " + name);
{
"name": "Alice",
"email": "alice@example.com"
}
SELECT * FROM users WHERE email LIKE '%@example.com';
<div class="user">
<strong>Alice</strong>
</div>
Released under the MIT License β © 2024β2025
MyAppz.com
This project is not affiliated with or endorsed by the PHP Foundation.
Use at your own risk β no warranties, no guarantees, just useful code.