PHP code example of dupot / static-generation-skeleton
1. Go to this page and download the library: Download dupot/static-generation-skeleton 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/ */
dupot / static-generation-skeleton example snippets
namespace MyWebsite\Pages;
use Dupot\StaticGenerationFramework\Page\PageAbstract;
use Dupot\StaticGenerationFramework\Page\PageInterface;
use MyWebsite\Components\HomeWelcomeComponent;
use MyWebsite\Components\NavComponent;
class HomePage extends PageAbstract implements PageInterface
{
const FILENAME = 'index.html';
public function getFilename(): string
{
return self::FILENAME;
}
public function render(): string
{
return $this->renderLayoutWithParamList(
__DIR__ . '/layout/default.php',
[
'nav' => new NavComponent($this->getFilename()),
'contentList' => [
new HomeWelcomeComponent(),
]
]
);
}
}
namespace MyWebsite\Components;
use Dupot\StaticGenerationFramework\Component\ComponentAbstract;
use Dupot\StaticGenerationFramework\Component\ComponentInterface;
use MyWebsite\Pages\HomePage;
class NavComponent extends ComponentAbstract implements ComponentInterface
{
protected $pageSelected;
public function __construct($pageSelected)
{
$this->pageSelected = $pageSelected;
}
public function render(): string
{
$linkList = [
'Home' => HomePage::FILENAME,
];
return $this->renderViewWithParamList(
__DIR__ . '/Nav/nav.php',
[
'linkList' => $linkList,
'pageSelected' => $this->pageSelected
]
);
}
}