首頁  >  文章  >  php框架  >  聊聊valet是否有適合TP5的驅動程式?

聊聊valet是否有適合TP5的驅動程式?

藏色散人
藏色散人轉載
2021-10-21 17:22:181962瀏覽

下面thinkphp框架教學專欄將介紹關於valet是否有適合thinkphp5的驅動程式的問題,希望對需要的朋友有幫助!

valet 有沒有適合thinkphp5的驅動程式?

覺得valet的思路很好所以採用了這個來做環境。

公司裡面用thinkphp的人比較多。所以要使用thinkphp。 (而且我是弄前端的,後端用啥也不會特別在意)

https://github.com/curder/blog/blob/master/tools/valet_support_thinkphp.md

這是thinkphp3-valet的。

↓↓↓↓↓↓↓

自己簡單寫了一個現在試的可以用。

<?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&#39;s front controller.
     *
     * @param  string  $sitePath
     * @param  string  $siteName
     * @param  string  $uri
     * @return string
     */
    public function frontControllerPath($sitePath, $siteName, $uri)
    {
        $_SERVER[&#39;SCRIPT_FILENAME&#39;] = &#39;index.php&#39;;
        $_SERVER[&#39;SCRIPT_NAME&#39;] = &#39;&#39;;
        $_SERVER[&#39;PHP_SELF&#39;] = &#39;/index.php&#39;;
        $_SERVER[&#39;PATH_INFO&#39;] = $uri;
        return $sitePath.&#39;/index.php&#39;;
    }
}

推薦:《最新的10個thinkphp影片教學

以上是聊聊valet是否有適合TP5的驅動程式?的詳細內容。更多資訊請關注PHP中文網其他相關文章!

陳述:
本文轉載於:segmentfault.com。如有侵權,請聯絡admin@php.cn刪除