定制 lighthouse/skeleton 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

lighthouse/skeleton

最新稳定版本:v0.1.0

Composer 安装命令:

composer create-project lighthouse/skeleton

包简介

Lighthouse Framework Application Skeleton

README 文档

README

A fresh Lighthouse Framework application.

Installation

composer create-project lighthouse/skeleton my-app
cd my-app

Development Server

Start the built-in PHP server:

composer start

Then visit http://localhost:8000

Project Structure

my-app/
├── config/
│   └── app.php          # Application configuration
├── public/
│   ├── index.php        # Entry point
│   └── .htaccess        # Apache rewrite rules
├── routes/
│   └── web.php          # Route definitions
├── src/
│   └── Controllers/     # Your controllers
├── views/
│   ├── layouts/         # Layout templates
│   └── *.php            # View templates
├── tests/               # Test files
├── .env.example         # Environment template
└── composer.json

Configuration

Copy .env.example to .env and adjust settings:

cp .env.example .env

Or configure directly in config/app.php.

Creating Routes

Edit routes/web.php:

// Closure route
$app->get('/hello', function () {
    return 'Hello, World!';
});

// Controller route
$app->get('/users', [UserController::class, 'index']);

// Route with parameter
$app->get('/users/{id}', [UserController::class, 'show']);

// Route group
$app->group('/api', function ($router) {
    $router->get('/users', [ApiUserController::class, 'index']);
});

// Named route
$app->get('/profile', [ProfileController::class, 'show'])->name('profile');

Creating Controllers

Create a new controller in src/Controllers/:

<?php

namespace App\Controllers;

use Lighthouse\Controller;
use Psr\Http\Message\ResponseInterface;

class UserController extends Controller
{
    public function index(): ResponseInterface
    {
        return $this->view('users.index', [
            'users' => $this->getUsers(),
        ]);
    }

    public function show(string $id): ResponseInterface
    {
        return $this->json([
            'id' => $id,
            'name' => 'John Doe',
        ]);
    }
}

Creating Views

Create views in views/:

views/users/index.php:

<?php $view->extends('layouts.main'); ?>

<?php $view->section('content'); ?>
<h1>Users</h1>
<ul>
    <?php foreach ($users as $user): ?>
        <li><?= $view->e($user['name']) ?></li>
    <?php endforeach; ?>
</ul>
<?php $view->endSection(); ?>

Testing

composer test

Deployment

For production:

  1. Set APP_DEBUG=false in your environment
  2. Point your web server to the public/ directory
  3. Ensure all requests are routed to public/index.php

Nginx Configuration

server {
    listen 80;
    server_name example.com;
    root /var/www/my-app/public;
    index index.php;

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    location ~ \.php$ {
        fastcgi_pass unix:/var/run/php/php8.2-fpm.sock;
        fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
        include fastcgi_params;
    }
}

Learn More

License

MIT

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-12-17

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固