ericktucto/touch
最新稳定版本:v1.0.2-alpha
Composer 安装命令:
composer require ericktucto/touch
包简介
Microframework for web applications
README 文档
README
Microframework PHP, create to web applications with Touch
Table of contents
Install with Composer
composer require ericktucto/touch
Steps to create basic application
1. Create config.yml
env: local # local or production
2. Create index.php file
<?php require __DIR__ . '/../vendor/autoload.php'; use Touch\Application; use Touch\Core\Kernel; use Touch\Http\Response; $app = Application::create(new Kernel()); $app->route()->get("/", fn() => Response::html("Hello world!!!")); $app->run();
Integrated packages
- PHP Dig (dependency injection container)
- Routing by thephpleague (use psr-7 and psr-15 to middleware)
- Eloquent (ORM's Laravel)
- Twig (engine template of Symfony)
- Clockwork (debugger console)
- Valitron (validation data request)
Ecosystem
Routing
Create your routing web applications
<?php // code ... $app->route()->get("/", fn () => Response::html("My index")); $app->router()->get("/login", [AuthController::class, "login"]); // AuthController.php class AuthController { public function login(Request $request) { // code.. } }
To more infor, you'll visit docs of The php league's Routing. But Touch have some interesed features.
Response class
Routing always need a function return a variable that implements Psr\Http\Message\ResponseInterface (see doc). To make returning response, exists Touch\Http\Response
<?php // code ... // return html or text plain, $status is optional and 200 is default value $app->route("/html", fn () => Response::html("<h3>My first app</h3>", 200)); // return json, $status is optional and 200 is default value $app->route("/api/v1/json", fn () => Response::json(["message" => "It's okay"], 200); // first argument can be a object
Grouping routes
Routing can group routes (see docs), but you have Touch\Http\Route to group on class.
<?php // index file $app->group('/admin', new AdminRoutes); // AdminRoutes.php use League\Route\RouteGroup; use Touch\Http\Response; use Touch\Http\Route; class AdminRoutes extends Route { protected function routes(RouteGroup $group) { $group->get('/users', [UserController::class, "create"]); $group->get('/list-users', fn() => Response::html("<!-- list users -->")); } } // routes created // GET /admin/users -> create method of UserController class // GET /admin/list-users -> anonymous closure
统计信息
- 总下载量: 9
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 4
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-04-06