我使用的是 advance 版,根据文档去
cd ~/Users/gpf/.valet/Drivers
vi YiiAdvanceValetDriver.php
//文件内容
<?php
class YiiAdvanceValetDriver 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)
{
if (file_exists($sitePath.'/backend/web')) {
return true;
}
return false;
}
/**
* 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.'/backend/web/'.$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)
{
return $sitePath.'/backend/web/index.php';
}
}
创建了一个驱动配置,然后进入文件路之后执行的link
cd /path/to/app/admin
valet link new.admin
然后浏览器访问 new.admin.dev
的时候报的错误是
这个我自己的理解是 yii是按照 valet 给出的路径去加载yii 需要的静态文件去了,但是请求路径明显不对啊,这种情况下我该怎么办?
有现成的驱动,不用自己写 https://github.com/incodenz/y...
如果你Yii2的项目的绝对路径是~/sites/gee
来到~/sites/gee/frontend/web 这是Yii2项目默认的前台入口目录,执行 valet link gee
再来到~/sites/gee/backend/web 执行 valet link admin.gee
就可以通过http://gee.test 打开前台,http://admin.gee.test 打开后台