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

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

藏色散人
Release: 2021-10-21 17:22:18
forward
2025 people have browsed it

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;;
    }
}
Copy after login

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!

Related labels:
source:segmentfault.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template