larafony/skeleton
Composer 安装命令:
composer create-project larafony/skeleton
包简介
Larafony Framework Application Skeleton
README 文档
README
Full-featured demo application for the Larafony Framework showcasing real-world usage patterns and best practices.
What's Included
This application demonstrates:
🗄️ Database & ORM
- Active Record ORM with relationship management
- belongsTo - Note → User relationship
- hasMany - User → Comments, Note → Comments
- belongsToMany - Note ↔ Tags (pivot table)
- Query Builder with fluent API
- Migrations using Schema Builder
- Seeders for demo data
🎨 Views & Templates
- Blade Template Engine with custom directives
- Components (Layout, Alert, InfoCard, StatusBadge)
- Slots for component composition
- @if, @foreach, @component directives
- Nested components with proper compilation
🔄 Data Handling
- Form Requests (DTOs) with automatic validation
- Type-safe data transfer using PHP 8.5 property hooks
- Union type support (string|array|null)
- Automatic hydration from HTTP requests
🛣️ Routing & Controllers
- Attribute-based routing -
#[Route('/path', 'METHOD')] - Controller base class with helpers (view, json, redirect)
- Automatic DTO injection via FormRequestAwareHandler
- RESTful API endpoints with JSON responses
💻 Console Commands
- Interactive setup command -
build:notes - Database connection testing
- Automatic migration runner
- Data seeding
⚙️ PHP 8.5 Features
- Property hooks for computed properties
- Asymmetric visibility -
public protected(set) - Attributes for routing and relationships
- Union types and null-safe operators
Installation
composer create-project larafony/skeleton my-app
cd my-app
Setup
Run the interactive installation command:
php8.5 bin/larafony build:notes
The installer will:
- Check your database connection
- Prompt for database credentials if needed (interactive setup)
- Create the database if it doesn't exist
- Run all migrations
- Seed demo data (user, tags, notes)
Note: The command will automatically configure your .env file based on your input.
Development Server
Start the built-in PHP server:
php -S localhost:8000 -t public
Visit: http://localhost:8000/notes
Features Showcase
📝 Web Interface - /notes
The notes application demonstrates a complete CRUD workflow:
List Notes
- Displays all notes with user, tags, and comment count
- Shows relationship loading (N+1 prevention)
- Blade components for consistent UI
Create Note
- HTML form with validation
- Tag creation and attachment (many-to-many)
- DTO-based request handling
- Automatic tag parsing (comma-separated)
View Note Details
- Author information (belongsTo)
- All tags (belongsToMany)
- All comments (hasMany)
🔌 API Endpoints
GET /api/notes - List all notes with relations
{
"notes": [
{
"id": 1,
"title": "Welcome to Larafony",
"content": "...",
"user": { "id": 1, "name": "Admin" },
"tags": [ { "id": 1, "name": "framework" } ],
"comments": [ { "id": 1, "content": "Great!" } ]
}
]
}
POST /api/notes - Create new note
{
"title": "My Note",
"content": "Note content",
"tags": ["php", "framework"]
}
POST /api/comments - Add comment
{
"note_id": 1,
"content": "This is a comment"
}
💡 Code Examples
ORM Relationships with Attributes
class Note extends Model { #[BelongsTo(related: User::class, foreign_key: 'user_id')] public ?User $user { get => $this->relations->getRelation('user'); } #[BelongsToMany( related: Tag::class, pivot_table: 'note_tag', foreign_pivot_key: 'note_id', related_pivot_key: 'tag_id' )] public array $tags { get => $this->relations->getRelation('tags'); } }
DTO with Property Hooks
class CreateNoteDto { #[IsValidated] public protected(set) string|array|null $tags { get { if (!isset($this->tags)) return null; if (is_array($this->tags)) return $this->tags; return array_map('trim', explode(',', $this->tags)); } set => $this->tags = $value; } }
Controller with Automatic DTO Injection
#[Route('/notes', 'POST')] public function store(CreateNoteDto $dto): ResponseInterface { // $dto is automatically created and validated from request $note = new Note()->fill([ 'title' => $dto->title, 'content' => $dto->content, ]); $note->save(); if ($dto->tags) { $note->attachTags($tagIds); } return $this->redirect('/notes'); }
Requirements
- PHP 8.5 or higher
- MySQL/PostgreSQL/SQLite
- Composer
License
MIT
larafony/skeleton 适用场景与选型建议
larafony/skeleton 是一款 基于 Blade 开发的 Composer 扩展包,目前已累计 36 次下载、GitHub Stars 达 12, 最近一次更新时间为 2025 年 10 月 26 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 larafony/skeleton 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 larafony/skeleton 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 36
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 12
- 点击次数: 7
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-10-26