定制 ericktucto/touch 二次开发

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

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

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

  1. PHP Dig (dependency injection container)
  2. Routing by thephpleague (use psr-7 and psr-15 to middleware)
  3. Eloquent (ORM's Laravel)
  4. Twig (engine template of Symfony)
  5. Clockwork (debugger console)
  6. 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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-04-06

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固