PHP code example of itecho / brickphp
1. Go to this page and download the library: Download itecho/brickphp 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/ */
itecho / brickphp example snippets
use BrickPHP\Brick;
use App\App;
namespace App;
use BrickPHP\State\SessionStateManager;
use BrickPHP\State\StateManager;
use BrickPHP\UI\UI;
use BrickPHP\VNode\App as BrickApp;
use BrickPHP\VNode\Component;
use BrickPHP\VNode\VNode;
class App extends BrickApp
{
public function title(): string { return 'Counter'; }
public function state(): StateManager
{
return new SessionStateManager();
}
protected function view(): VNode
{
return new Counter();
}
}
class Counter extends Component
{
private int $count = 0;
protected function initialize(): void
{
$this->useState($this->count);
}
protected function build(): VNode
{
return UI::column()->content(
UI::text("Count: {$this->count}"),
UI::button('+')->onClick(fn() => $this->count++),
);
}
}