thinkphp5 配置在sae,axios请求出现500!
但在Network中是有数据请求到的。
在直接访问php的function 也是可以正常渠道数据,但一瞬间也出现500,数据出来就没有了。
这是因为:sae不支持文件写入,所以thinkphp没法写入日志,然后异常了
这是官方的参考:https://www.kancloud.cn/manual/thinkphp5/175109
-------------------------------------------华丽三八线--------------------------------------------------------------------
默认的 ThinkPHP 5 需要写入到本地文件,这在 SAE 上是不允许的。ThinkPHP 团队提供了 SAE 的扩展:
https://github.com/top-think/think-sae 把 SAE 扩展的 src 目录下三个 PHP 文件复制到 tp5/thinkphp/library/think/sae 下。
这里 sae 这个目录是不存在的,需要自己创建
在 public/index.php 里定义一个常量来标识是不是在SAE环境中:
1 define("IN_SAE", defined("SAE_MYSQL_USER"));
然后在配置文件config.php里,可以这样:
1 'log'=>[ 2 'type' => IN_SAE ? '\think\sae\Log' : 'File', 3 ]
'log' => [
'type' => '\think\sae\Log',
]
'template' => [
'type' => 'Think',
'compile_type' => '\think\sae\Template',
]
'cache' => [
'type' => '\think\sae\Cache',
]
按照官方写法的话! 如果你没开新浪云的
Memcached缓存就会报错。