lizzyman04/fluxor
Composer 安装命令:
composer require lizzyman04/fluxor
包简介
A lightweight PHP MVC engine with file-based routing and elegant Flow syntax.
关键字:
README 文档
README
The lightweight PHP MVC core that powers Fluxor framework - File-based routing, elegant Flow syntax, and zero bloat.
📦 What is Fluxor Core?
Fluxor Core is the engine behind the Fluxor PHP framework - a minimal, elegant, and powerful MVC core designed for developers who want simplicity without sacrificing functionality.
Unlike monolithic frameworks, Fluxor Core gives you:
- 🚀 Blazing fast performance (boot under 10ms)
- 📦 Minimal dependencies - routing is powered by the standalone, zero-dependency
lizzyman04/file-routerpackage; nothing else - 🔍 Transparent code - no magic, you can read everything
- 🎯 File-based routing inspired by Next.js
- 💎 Elegant Flow syntax for route definitions
- 🔒 Config locking to protect critical settings
- 🌐 Built-in CORS support (global + per-route)
🚀 Quick Start
composer require lizzyman04/fluxor
<?php require 'vendor/autoload.php'; $app = new Fluxor\Core\App(); $app->run();
🎯 Imports
Import core classes from their namespaces (PSR-4 autoloaded):
use Fluxor\Core\App; use Fluxor\Core\Http\Request; use Fluxor\Core\Http\Response; use Fluxor\Core\Routing\Flow; use Fluxor\Core\View;
Breaking change in 2.0: the short-name aliases
Fluxor\Flow,Fluxor\App,Fluxor\Response, etc. were removed. Use the fully-qualified namespaces above.
💡 Core Concepts
Application Instance
$app = new Fluxor\Core\App(); $basePath = $app->getBasePath(); // Auto-detected! $baseUrl = $app->getBaseUrl(); // Auto-detected!
Global CORS Configuration
$app = new Fluxor\Core\App(); $app->cors()->allowOrigin('*')->enable(); $app->run();
File-based Routing
The directory structure is the route table. URL matching (dynamic [id],
catch-all [...slug], route groups, the compiled-route cache) is handled by
the standalone lizzyman04/file-router
engine; Fluxor adds the Flow syntax and dispatch on top. The route-file
syntax below is unchanged.
// app/router/users/[id].php use Fluxor\Core\Routing\Flow; use Fluxor\Core\Http\Response; Flow::GET()->do(function($req) { $userId = $req->param('id'); return Response::success(['user' => $userId]); });
Router with Middleware
$router = $app->getRouter(); $router->addMiddleware('auth', function($request) { if (!$request->isAuthenticated()) { return Fluxor\Core\Http\Response::redirect('/login'); } });
Request & Response
use Fluxor\Core\Http\Response; $id = $request->param('id'); $email = $request->input('email'); $token = $request->bearerToken(); return Response::json(['user' => $user]); return Response::view('profile', ['user' => $user]);
Flow Syntax
use Fluxor\Core\Routing\Flow; // Simple route Flow::GET()->do(fn($req) => 'Hello World'); // Controller binding Flow::POST()->to(UserController::class, 'store'); // Middleware Flow::use(fn($req) => $req->isAuthenticated() ? null : redirect('/login'));
View System
// In controller return Response::view('home', ['title' => 'Home']); // In view (home.php) View::extend('layouts/main'); View::section('content'); <h1><?= View::e($title) ?></h1> View::endSection();
Global Helpers
// Environment variables $debug = env('APP_DEBUG', false); $dbName = env('DB_NAME', 'database'); // Path helpers $root = base_path(); $url = base_url('api/users'); $asset = asset('css/app.css'); // HTTP helpers abort(404, 'Not Found'); return redirect('/dashboard'); // Debug helpers dump($user); dd($data); // Dump and die
📚 Documentation
Full documentation available at: 👉 https://fluxor.tudocomlizzyman.com
The documentation includes:
- Installation guide
- File-based routing
- Flow syntax reference
- Views and layouts
- Controllers and middleware
- Environment configuration
- Complete API reference with helper functions
📄 License
MIT License - see LICENSE file for details.
Fluxor - Build elegant PHP applications with joy! 🎉
统计信息
- 总下载量: 111
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 15
- 点击次数: 14
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-03-17