鍍金池/ 問(wèn)答/PHP/ valet 有沒(méi)有適合thinkphp5的驅(qū)動(dòng)。之前看有人寫了個(gè)3的仿寫了一下還

valet 有沒(méi)有適合thinkphp5的驅(qū)動(dòng)。之前看有人寫了個(gè)3的仿寫了一下還是不行

覺(jué)得valet的思路很好所以采用了這個(gè)來(lái)做環(huán)境。
公司里面用thinkphp的人比較多。所以要使用thinkphp。(而且我是弄前端的,后端用啥也不會(huì)特別在意)
https://github.com/curder/blo...
這是thinkphp3-valet的。

回答
編輯回答
愿如初

自己簡(jiǎn)單寫了一個(gè)現(xiàn)在試的可以用。

<?php

class ThinkPHP5ValetDriver 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.$uri)) {
            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'] = 'index.php';
        $_SERVER['SCRIPT_NAME'] = '';
        $_SERVER['PHP_SELF'] = '/index.php';
        $_SERVER['PATH_INFO'] = $uri;
        return $sitePath.'/index.php';
    }
}
2017年10月5日 23:15