1. Go to this page and download the library: Download dvaknheo/duckphp 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/ */
dvaknheo / duckphp example snippets
DuckPhp\DuckPhpAllInOne;
use DuckPhp\Foundation\Controller\Helper;
use MyApp as MyWelcomeController;
use MyApp as MyBusiness;
use MyApp as MyModel;
use MyApp as MyView;
use DuckPhp\DuckPhpAllInOne;
use DuckPhp\Foundation\Controller\Helper;
use MyApp as MyWelcomeController;
use MyApp as MyBusiness;
use MyApp as MyModel;
use MyApp as MyView;
class MyApp extends DuckPhpAllInOne
{
public $options = [
'path' => __DIR__,
'controller_welcome_class' => MyWelcomeController::class,
'callable_view_class' => MyView::class,
// ...
];
//@override
public function onInited()
{
Helper::setViewHeadFoot('', '');
}
public function action_index()
{
$words = MyBusiness::_()->getTime();
Helper::Show(['words' => $words], 'main');
}
public function view_main($data)
{
$url = __url('');
echo "You are visit: $url; {$data['words']}";
}
public function getTime()
{
return "Hello, now is <" . MyModel::_()->getData() . '>';
}
public function getData()
{
return DATE(DATE_ATOM);
}
}
MyApp::RunQuickly([]);
DuckPhp\DuckPhpAllInOne;
class ChildApp extends DuckPhpAllInOne
{
public function action_index()
{
echo "I'm child.";
}
}
class ParentApp extends DuckPhpAllInOne
{
public $options = [
'app' => [
ChildApp::class => [
'controller_url_prefix' => 'child/',
],
]
];
public function action_index()
{
$url_child = __url('child/index');
echo "I'm Parent. Goto <a href='{$url_child}'>child</a>";
}
}
ParentApp::RunQuickly([]);
DuckPhp\DuckPhpAllInOne as DuckPhpAllInOne;
use DuckPhp\Core\CoreHelper;
function __h($str)
{
return CoreHelper::H($str);
}
class MyCoreHelper extends CoreHelper
{
//@override
public function _H(&$str)
{
return '<b>' . CoreHelper::_H($str) . '</b>';
}
}
class ExtApp extends DuckPhpAllInOne
{
//@override
public function onInited()
{
CoreHelper::_(MyCoreHelper::_());
ExtApp::setViewHeadFoot('', '');
}
public function action_index()
{
ExtApp::Show([], 'main');
}
public function view_main($data)
{
echo __h('<h!>');
}
}
$options = [
'path' => __DIR__,
];
ExtApp::RunQuickly($options);
bash
php sample1.php run --host 127.0.0.1 --port 9628 --path-document .
You are visit: /sample1.php; Hello, now is <2026-07-11T07:08:05+00:00>
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.