承接 tonka/astro 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

tonka/astro

Composer 安装命令:

composer create-project tonka/astro

包简介

Tonka Framework InertiaJs ReactJs Starter Kit

README 文档

README

The official React Starter Kit for the Tonka Framework.

Tonka Astro provides a seamless integration between your PHP backend and your React frontend. It comes pre-configured with InertiaJS, DriftQL, and Tonka Router, offering a development experience similar to Laravel's Inertia stack, but optimized for the Tonka ecosystem.

🌟 Key Features

  • ⚛️ React + Vite: A modern, blazing-fast frontend environment with Hot Module Replacement (HMR).
  • 🚀 InertiaJS: Build single-page applications without building an API. Server-side routing meets client-side rendering.
  • 🧠 DriftQL Integration: Access your Elegant ORM models directly in your JSX with the powerful <Elegant> component.
  • 🛣️ Tonka Router: Use your backend named routes in your React components effortlessly.
  • 🛠️ Zero Config: Out-of-the-box configuration for TypeScript, Tailwind CSS (optional), and build tools.

📦 Installation

Install the package via Composer into your Tonka project:

composer create-project tonka/astro astro-app

Navigate to the astro-app directory, then run:

npm install

This will scaffold the frontend structure and install NPM dependencies.

🚀 Quick Start

Once installed, your resources/js directory is ready to go.

1. The Entry Point

Your React app is automatically wired to your backend via Inertia.

// resources/js/App.tsx
import { usePage } from '@inertiajs/react';
import { route } from 'tonka-router'; // Auto-imported via Spark

export default function App() {
  return (
    <main>
      <h1>Welcome to Tonka Astro</h1>
      <a href={route('login')}>Login</a>
    </main>
  );
}

2. Fetching Data with DriftQL

Query your backend database without writing API calls. Use the <Elegant> component to bind data to DOM elements or use Render Props.

import { Elegant } from 'driftql-react';

export default function UserProfile() {
  return (
    <div>
      <h1>My Profile</h1>
      
      {/* Auto-Binding: Fills src automatically from DB */}
      <Elegant 
        as="img" 
        resource="User" 
        id={1} 
        data-src="avatar_url" 
        className="rounded-full"
      />

      {/* Render Props: Full control */}
      <Elegant resource="Post" limit={5}>
        {(loading, error, posts) => (
          loading ? <p>Loading...</p> : (
            <ul>
              {posts.map(post => <li key={post.id}>{post.title}</li>)}
            </ul>
          )
        )}
      </Elegant>
    </div>
  );
}

3. Navigation with Tonka Router

Navigate using your backend route names. Tonka Router handles URL generation automatically based on your Spark configuration.

import { route, current } from 'tonka-router';

export default function Navbar() {
  return (
    <nav>
      <a href={route('home')}>Home</a>
      <a href={route('posts.index')}>Posts</a>
      
      {/* Highlight active link */}
      <a href={route('profile')} style={{ color: current().name === 'profile' ? 'blue' : 'black' }}>
        Profile
      </a>
    </nav>
  );
}

📁 Project Structure

The kit organizes your frontend code cleanly within the Tonka structure:

tonka-project/
├── app/                # Backend Logic (Controllers, Models)
├── resources/
│   ├── js/             # React Frontend (Scaffolded by Astro)
│   │   ├── App.tsx
│   │   ├── Pages/      # Inertia Pages
│   │   └── Components/ # Reusable React Components
│   └── views/          # Twig Templates (for initial load)
├── public/             # Public Assets
└── vite.config.js      # Vite Configuration

⚙️ Configuration

Frontend Config (drift.config.js)

Located at the root of your project, generated by Astro.

export default {
  baseURL: '/api/bridge',
  bridge_public_key: 'your-key-here',
  // ...
};

Backend Config (config/spark.php)

Configure which routes are visible to the frontend and apply access policies.

return [
    'only' => [
        ['name' => 'home', 'policy' => null],
        ['name' => 'admin.*', 'policy' => \App\Contracts\DriftQL\AdminPolicy::class],
    ],
];

🛠️ Development

Start the Vite development server:

npm run dev

Build for production:

npm run build

📚 Learn More

📝 License

MIT

tonka/astro 适用场景与选型建议

tonka/astro 是一款 基于 SCSS 开发的 Composer 扩展包,目前已累计 5 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 02 月 23 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「framework」 「reactjs」 「inertiajs」 「tonka」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 tonka/astro 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 tonka/astro 我们能提供哪些服务?
定制开发 / 二次开发

基于 tonka/astro 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 5
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 24
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: SCSS

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-02-23