定制 lizzyman04/mvccore 二次开发

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

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

lizzyman04/mvccore

Composer 安装命令:

composer require lizzyman04/mvccore

包简介

A lightweight PHP MVC core with Next.js-style file-based routing, elegant Flow syntax, and powerful features

README 文档

README

A lightweight, elegant PHP MVC framework with Next.js-style file-based routing and beautiful Flow syntax.

✨ Features

  • 🎯 File-based Routing - Like Next.js App Router
  • 💎 Elegant Flow Syntax - Ultra clean route definitions
  • 🔄 MVC Architecture - Clean separation of concerns
  • 🎨 Powerful View System - Layouts, sections, and stacks
  • 🛡️ Built-in Security - CSRF protection, validation
  • 🚦 Middleware Support - Flexible request processing
  • 🎭 Error Handling - Hierarchical error pages
  • 📦 Multiple Templates - Basic, MVC, and API starters

Quick Start

composer create-project lizzyman04/mvccore my-app
cd my-app
php -S localhost:8000 -t public

Visit http://localhost:8000

🎯 Elegant Routing

Create routes using the file system:

app/router/
├── page.php                 # GET /
├── api/
│   └── hello/
│       └── index.php       # GET /api/hello  
└── posts/
    └── [slug]/
        └── index.php       # GET /posts/{slug}

Example Route

<?php
// app/router/posts/[slug]/index.php

use MVCCore\Flow;
use MVCCore\Core\Response;

Flow::GET()->do(fn($req) => 
    Response::success(['slug' => $req->param('slug')])
);

Flow::PUT()->to(PostController::class, 'update');

return Flow::execute($req);

💎 Beautiful Flow Syntax

// Ultra clean route definitions
Flow::GET()->do(fn($req) => Response::json(['hello' => 'world']));
Flow::POST()->to(Controller::class, 'store');
Flow::use(fn($req) => $req->isAuthenticated() ? null : Response::redirect('/login'));

🏗️ Three Template Options

1. Basic Template

composer create-project lizzyman04/mvccore my-app
# Choose "basic"

2. MVC Template (Authentication + Views)

composer create-project lizzyman04/mvccore my-app
# Choose "mvc"

3. API Template (RESTful API)

composer create-project lizzyman04/mvccore my-app  
# Choose "api"

📖 Documentation

Routing

Create files in app/router/ to define routes:

  • page.php/
  • about.php/about
  • posts/index.php/posts
  • posts/[slug]/index.php/posts/any-slug
  • (auth)/login/index.php/auth/login

Flow Methods

Flow::GET()->do(fn($req) => ...);
Flow::POST()->to(Controller::class, 'method');
Flow::PUT()->do(function($req) { ... });
Flow::DELETE()->to(Controller::class);
Flow::any(fn($req) => ...);
Flow::use(middleware);

Response Types

Response::success($data, 'Message');
Response::error('Error message', 400);
Response::view('template', $data);
Response::json($data);
Response::redirect('/path');

Views with Layouts

// In controller
return Response::view('home', ['title' => 'Home']);

// In view template
$this->extend('layouts/main');
$this->section('content');
// Your content
$this->endSection();

🛠️ Configuration

Create .env file:

APP_NAME="My MVCCore App"
APP_ENV=development
APP_DEBUG=true
APP_URL=http://localhost:8000

🎨 Custom Error Pages

Create hierarchical error handlers:

app/router/
├── not-found.php           # Global 404
├── 404.php                # Alternative 404
├── api/
│   └── 404.php            # API-specific 404
└── (auth)/
    └── 401.php            # Auth-specific 401

📦 Installation

Via Composer

composer require lizzyman04/mvccore

Manual Installation

git clone https://github.com/lizzyman04/mvccore.git
cd mvccore
composer install

🔧 Development

Run tests:

composer test

Run with coverage:

composer test-coverage

🤝 Contributing

We welcome contributions! Please:

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests
  5. Submit a pull request

📄 License

MIT License - see LICENSE file for details.

🆕 Changelog

v1.0.0

  • Initial release
  • File-based routing system
  • Elegant Flow syntax
  • Three starter templates
  • Hierarchical error handling

MVCCore - Build elegant PHP applications with joy! 🎉

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-10-27