跳转到正文

全栈区块

数据库、服务器函数、cron 和 CLI 都在同一个文件夹中。

db.php

定义架构,即可获得 CRUD 端点

db.php
<?php
return [
  'storage'    => 'sqlite',
  'userScoped' => true,
  'capability' => [
    'create' => true,
    'read'   => true,
    'update' => true,
    'delete' => true,
  ],
  'fields' => [
    'text' => ['type' => 'string', 'required' => true],
    'done' => ['type' => 'boolean', 'default' => false],
  ],
];

rpc.php

自定义服务器函数

rpc.php
<?php
use Blockstudio\Db;

return [
  'toggle' => function (array $params): array {
    $db   = Db::get('my-theme/todo');
    $id   = (int) ($params['id'] ?? 0);
    $todo = $db->get_record($id);
    if ($todo) {
      $db->update($id, ['done' => !$todo['done']]);
    }
    return ['success' => (bool) $todo];
  },
  'clear_done' => function (): array {
    $db = Db::get('my-theme/todo');
    foreach ($db->list(['done' => true], 500) as $todo) {
      $db->delete((int) $todo['id']);
    }
    return ['cleared' => true];
  },
];

每项功能都是一个文件

每个文件添加一项功能。无需配置,也无需注册代码。

应用程序区块

blockstudio/

└── my-app/

├── block.json 区块定义

├── index.php 模板 + 交互性 API

├── style.css 作用域样式

├── script-inline.js 客户端逻辑

├── db.php 数据模型 + CRUD

├── rpc.php 服务器函数

├── cron.php 计划任务

└── db/default.sqlite

数据库

定义架构,即可获得 CRUD 端点。

RPC

可从前端调用的服务器函数。

客户端数据层

在浏览器中读取、缓存和写入记录。

表单和应用界面

根据 schema 渲染表单,并提供打包好的 UI 作为构建基础。

基础设施

Cron、CLI、设置代码和可移植性。

Plus

官方扩展套件

高级站点模板、AI 系统指令和私人 Discord 社区。一次购买,终身更新。

  • 500+ 个网站模板
  • AI 系统指令
  • 终身更新
  • 私有 Discord 社区