我試圖找出如何更改Lumen項目上的默認存儲位置(包括它的子文件夾)。由於多種原因,考慮到生產Web服務器的當前配置,Lumen在嘗試編寫日誌或編譯刀片視圖時會拋出權限被拒絕異常。流明 - 更改默認存儲路徑
不涉及sysadmin的唯一選擇是將存儲文件夾移動到Web服務器上的tmp文件夾。
在laravel上,似乎有一種名爲「useStoragePath」的方法,但它似乎在Lumen(5.2.x)上不可用。
的默認路徑似乎是 「硬編碼」,我發現這一點:
Project\vendor\laravel\lumen-framework\src\Application.php
/**
* Get the storage path for the application.
*
* @param string|null $path
* @return string
*/
public function storagePath($path = null)
{
return $this->basePath().'/storage'.($path ? '/'.$path : $path);
}
而對於日誌(同一個文件):
/**
* Get the Monolog handler for the application.
*
* @return \Monolog\Handler\AbstractHandler
*/
protected function getMonologHandler()
{
return (new StreamHandler(storage_path('logs/lumen.log'), Logger::DEBUG))
->setFormatter(new LineFormatter(null, null, true, true));
}
底線:有沒有乾淨的方式覆蓋默認存儲路徑牢記這個限制?:
- 我的t不應該涉及sysadmin(sym鏈接,更改權限等)
- 不篡改供應商文件夾。