pagilla/core

PHP模板引擎,灵感来源于React和Flutter。

dev-master 2024-08-12 21:22 UTC

This package is auto-updated.

Last update: 2024-09-12 21:45:46 UTC


README

CI build

关于

Pagilla是一个受到Flutter启发的PHP组件引擎。使用纯PHP创建您的表现层。

安装

composer install pagilla/core

使用方法

此Pagilla代码

<?php

namespace MyApp\Page;

use Pagilla\Core\Component\RenderedComponent;
use Pagilla\Component\WebApp;

class HomePage extends RenderedComponent
{
    public function build(): RenderedComponent
    {
        return new WebApp(
            title: 'My new Pagilla web app',
            child: new Grid(
                children: [
                    new Row(
                        children: [
                            new Column(
                                children: [
                                    new Text('Column 1'),
                                ]
                            ),
                            new Column(
                                children: [
                                    new Text('Column 2'),
                                ]
                            ),
                            new Column(
                                children: [
                                    new Text('Column 3'),
                                ]
                            ),
                        ],
                    ),
                ],
            ),
        );
    }
}

渲染

<!doctype html>
<html lang="pl">
    <head>
        <meta charset="utf-8" />
        <title>My new Pagilla web app</title>
    </head>
    <body>
        <div>
            <div style="display: flex; flex-direction: row;">
                <div style="display: flex: flex-direction: column">
                    <div>
                        Column 1
                    </div>
                </div>
                <div style="display: flex: flex-direction: column">
                    <div>
                        Column 2
                    </div>
                </div>
                <div style="display: flex: flex-direction: column">
                    <div>
                        Column 3
                    </div>
                </div>
            </div>
        </div>
    </body>
</html>

您只需在您的index.php文件中运行应用程序即可

<?php

use MyApp\Page\HomePage;
use Rwionczek\Pagilla\AppKernel;

require __DIR__ . '/vendor/autoload.php';

$kernel = new AppKernel();

$kernel->runApp(new HomePage());