ThinkPHP5 Valet Driver

刚刚在配置 Valet 驱动的时候,发现 ThinkPHP5 没有找到合适的驱动。

那就动手写一个吧:

https://github.com/huanghua581/ThinkPHP5Va...

重要提示:Mojave 10.14 驱动文件夹为:~/.config/valet/Drivers

相关文档:Valet《Laravel 5.7 中文文档》

php
Bazinga!
Cooper
《L05 电商实战》
从零开发一个电商项目,功能包括电商后台、商品 & SKU 管理、购物车、订单管理、支付宝支付、微信支付、订单退款流程、优惠券等
《L03 构架 API 服务器》
你将学到如 RESTFul 设计风格、PostMan 的使用、OAuth 流程,JWT 概念及使用 和 API 开发相关的进阶知识。
讨论数量: 2
chenvle

:joy: Thinkphp 6 的 怎么写

3年前 评论
Cooper (楼主) 3年前
chenvle (作者) 3年前
Cooper (楼主) 3年前
chenvle (作者) 3年前

TP6 测试可用:

<?php

class ThinkPHP6ValetDriver extends ValetDriver
{
    /**
     * Determine if the driver serves the request.
     *
     * @param  string  $sitePath
     * @param  string  $siteName
     * @param  string  $uri
     * @return bool
     */
    public function serves($sitePath, $siteName, $uri)
    {

        return true;
    }
    /**
     * Determine if the incoming request is for a static file.
     *
     * @param  string  $sitePath
     * @param  string  $siteName
     * @param  string  $uri
     * @return string|false
     */
    public function isStaticFile($sitePath, $siteName, $uri)
    {
        if (file_exists($staticFilePath = $sitePath . '/public' . $uri)
            && is_file($staticFilePath)) {
            return $staticFilePath;
        }

        return false;
    }
    /**
     * Get the fully resolved path to the application's front controller.
     *
     * @param  string  $sitePath
     * @param  string  $siteName
     * @param  string  $uri
     * @return string
     */
    public function frontControllerPath($sitePath, $siteName, $uri)
    {
        $_SERVER['SCRIPT_FILENAME'] = $sitePath . '/public/index.php';
        $_SERVER['SERVER_NAME']     = $_SERVER['HTTP_HOST'];
        $_SERVER['SCRIPT_NAME']     = '/index.php';
        $_SERVER['PHP_SELF']        = '/index.php';
        $_GET['s']                  = $uri;

        return $sitePath . '/public/index.php';
    }
}
3年前 评论

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!