PHP code example of icanboogie / view
1. Go to this page and download the library: Download icanboogie/view 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/ */
icanboogie / view example snippets
namespace App\Articles;
use ICanBoogie\Routing\Attribute\Get;
use ICanBoogie\View\View;
use ICanBoogie\View\ViewProvider;
final class ArticleController
{
public function __construct(
private readonly ViewProvider $view_provider,
private readonly ArticleRepository $articles,
) {
}
#[Get('/articles')]
public function list(): View
{
return $this->view_provider->view(
$this,
content: $this->articles->latest(10),
locals: [ 'title' => "Last ten articles" ],
);
}
}