1. Go to this page and download the library: Download jhuddle/framework library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
jhuddle / framework example snippets
<ul>
foreach($items as $item):
// Adjust paths to match your project structure:
// Instantiate app and define it as a constant:
define('app', new \Framework\App([
'view' => dir('../templates'),
]));
// Declare routes:
app->route->get('/',
function () {
print app->view('layout', [
'title' => "Home page",
'content' => "This is the home page.",
]);
}
);
app->route->get('/hello/<name
define('app', new \Framework\App([
'layout' => dir('../templates/layouts'),
'partial' => dir('../templates/partials'),
]));
print app->layout('song/lyrics', [
'title' => "The Lonely Goatherd",
'content' => implode("<br>", [
"High on a hill was a lonely goatherd,",
app->partial('yodel.php'),
"Loud was the voice of the lonely goatherd,",
app->partial('yodel.php', ['short' => true]),
"Folks in a town that was quite remote heard",
app->partial('yodel'), // adds `.php` if no suffix given
"Lusty and clear from the goatherd's throat, heard",
app->partial('yodel', ['short' => true]),
]),
]);
define('app', new \Framework\App([
'notes' => ["Do", "Re", "Mi",],
'lineFrom' => fn ($a, $b) => "$a - $b,\n",
]));
print "When you read you begin with A-B-C.\n";
print "When you sing you begin with " . implode("-", app->notes) . ".\n";
app->use([
'notes' => ["Do", "Re", "Mi", "Fa", "So", "La", "Ti",],
'memory_aids' => [
"a deer, a female deer",
"a drop of golden sun",
"a name I call myself",
"a long, long way to run",
"a needle pulling thread",
"a note to follow So",
"a drink with jam and bread",
],
]);
foreach (array_combine(app->notes, app->memory_aids) as $note => $memory_aid) {
print app->lineFrom($note, $memory_aid);
}
print "That will bring us back to " . app->notes[0] . "!";
class RelationshipController {
public static function depend() {
print "I'll depend on you";
}
public static function takeCare() {
print "I'll take care of you";
}
public static function prepare(string $men) {
$sanitized_men = htmlspecialchars(urldecode($men));
print "$sanitized_men - what do I know of those?";
}
}
define('app', new \Framework\App());
app->route->prefix('sixteen')
->get('/seventeen', [RelationshipController::class, 'depend'])
->get('/eighteen', [RelationshipController::class, 'takeCare'])
->get('/<men:string>', [RelationshipController::class, 'prepare'])
;
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.