Skip to content

Commit

Permalink
Merge pull request #71 from 645418484/thinkphp-recipes
Browse files Browse the repository at this point in the history
Thinkphp recipes
  • Loading branch information
joanhey committed Feb 27, 2024
2 parents e3d2e4d + 61f25c0 commit 137a52d
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 2 deletions.
26 changes: 26 additions & 0 deletions recipes/thinkphp-cn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Thinkphp 使用 Adapterman

[English](./thinkphp.md) | 中文

```shell
# 安装 adapterman 到你的项目
composer require joanhey/adapterman
# 启动
./vendor/bin/adapterman start
```
运行逻辑解释:
1.`./vendor/bin/adapterman start` 命令其实是执行了

/usr/bin/env php -c vendor/joanhey/adapterman/cli-php.ini vendor/joanhey/adapterman/src/start.php "$@"

2.php -c [vendor/joanhey/adapterman/cli-php.ini](https://github.com/joanhey/AdapterMan/blob/master/cli-php.ini) 将一些php内置函数禁用之后,adapterman框架实现这些禁用的函数,实现在fpm下的功能在 php cli 下正常运行

3.[vendor/joanhey/adapterman/src/start.php](https://github.com/joanhey/AdapterMan/blob/master/src/start.php) 文件将自动启动服务器,并自动检测正在使用的框架.
其中 [vendor/joanhey/adapterman/src/frameworks/index.php](https://github.com/joanhey/AdapterMan/blob/master/src/frameworks/index.php) 检测正在使用的框架

在浏览器访问

```http://localhost:8080```


或者使用
22 changes: 22 additions & 0 deletions recipes/thinkphp.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Thinkphp with Adapterman

English | [中文](./thinkphp-cn.md)

```shell
# install adapterman into your project
composer require joanhey/adapterman
# start
./vendor/bin/adapterman start
```
explain:
1.`./vendor/bin/adapterman start` Actually carried out

/usr/bin/env php -c vendor/joanhey/adapterman/cli-php.ini vendor/joanhey/adapterman/src/start.php "$@"

2.php -c [vendor/joanhey/adapterman/cli-php.ini](https://github.com/joanhey/AdapterMan/blob/master/cli-php.ini) After disabling some of the built-in php functions, the adapterman framework implements these disabled functions, so that the functions under fpm will work properly under the php cli

3.[vendor/joanhey/adapterman/src/start.php](https://github.com/joanhey/AdapterMan/blob/master/src/start.php) The file will automatically start the server and automatically detect which framework is being used.
among [vendor/joanhey/adapterman/src/frameworks/index.php](https://github.com/joanhey/AdapterMan/blob/master/src/frameworks/index.php) Detect the framework being used
View in your browser

```http://localhost:8080```
8 changes: 6 additions & 2 deletions src/frameworks/think.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

use think\Cache;
use think\Config;
use think\Console;
Expand All @@ -22,8 +23,11 @@ class Http extends think\Http
protected function loadMiddleware(): void
{
if (is_file($this->app->getBasePath() . 'middleware.php')) {
// Change include to include_once
$this->app->middleware->import(include_once $this->app->getBasePath() . 'middleware.php');
// Change include to include_once OnlyOne
$middleware = include_once $this->app->getBasePath() . 'middleware.php';
if (is_array($middleware)) {
$this->app->middleware->import($middleware);
}
}
}

Expand Down

0 comments on commit 137a52d

Please sign in to comment.