php is_writable 对于可写挂载总是返回 false

为了将我的应用程序转换为 laravel,我尝试创建一个新应用程序。我正在使用网络挂载来访问 linux 服务器上的文件。没有ssh访问。我的机器是Windows。服务器可作为网络安装访问。在安装的驱动器上创建 laravel-6 应用程序时出现此错误:


Generating optimized autoload files

> Illuminate\Foundation\ComposerScripts::postAutoloadDump

> @php artisan package:discover --ansi


In PackageManifest.php line 179:


  The R:\path\to\laravel\bootstrap\cache directory must be present and writable.



Script @php artisan package:discover --ansi handling the post-autoload-dump event returned with error code 1

在我可以读写的所有目录中。经过一些测试后,我发现is_writable对于驱动器上的文件(在 Windows 上)总是返回 false。这很愚蠢,因为我可以在驱动器上创建和修改文件(包括缓存目录)。我也在 cygwin 中尝试过它。同样的结果。


phpfileperms方法返回 formatted: 40777。所以我想它应该是可读可写的。PHP版本:7.3.9


如何配置我的 windows php 环境以将文件视为可写?


绝地无双
浏览 169回答 1
1回答

慕姐8265434

当您访问网络(smb 或 samba)文件时,这似乎是 php 中一个已知的错误。已经问过类似的问题:is_writable 为 NFS-share 返回 false,即使它对用户 www-data 是可写的阅读此内容以获取有关该错误的更多信息:https ://bugs.php.net/bug.php?id=68926不幸的是,这个问题的唯一解决方案(据我所知)是编写您自己的自定义is_writeable函数,如下所示:<?phpnamespace Same\As\One\You\Use\Them\In;function is_readable($file){&nbsp; &nbsp; if(file_exists($file) && is_file($file))&nbsp; &nbsp; {&nbsp; &nbsp; &nbsp; &nbsp; $f = @fopen($file, 'rb');&nbsp; &nbsp; &nbsp; &nbsp; if(fclose($f))&nbsp; &nbsp; &nbsp; &nbsp; {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return true;&nbsp; &nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; }&nbsp; &nbsp; return false;}function is_writable($file){&nbsp; &nbsp; $result = false;&nbsp; &nbsp; if(file_exists($file) && is_file($file))&nbsp; &nbsp; {&nbsp; &nbsp; &nbsp; &nbsp; $f = @fopen($file, 'ab');&nbsp; &nbsp; &nbsp; &nbsp; if(fclose($f))&nbsp; &nbsp; &nbsp; &nbsp; {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return true;&nbsp; &nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; }&nbsp; &nbsp; return false;}?>
打开App,查看更多内容
随时随地看视频慕课网APP