Home  >  Article  >  PHP Framework  >  Let's talk about whether valet has a driver suitable for TP5?

Let's talk about whether valet has a driver suitable for TP5?

藏色散人
藏色散人forward
2021-10-21 17:22:182006browse

The following thinkphp framework tutorial column will introduce to you the issue of whether valet has a driver suitable for thinkphp5. I hope it will be helpful to friends in need!

valet Is there a driver suitable for thinkphp5?

I think valet’s idea is very good, so I adopted this as the environment.

There are many people using thinkphp in the company. So use thinkphp. (And I am working on the front end, so I don’t particularly care what I use for the back end)

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

This is thinkphp3-valet.

↓↓↓↓↓↓↓

I simply wrote one that I can try now.

<?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;;
    }
}

Recommended: "The latest 10 thinkphp video tutorials"

The above is the detailed content of Let's talk about whether valet has a driver suitable for TP5?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:segmentfault.com. If there is any infringement, please contact admin@php.cn delete