運行時自動加載與我收到以下錯誤的PHP文件:致命錯誤使用PHP自動加載
Fatal error: Uncaught exception 'UnexpectedValueException' with message 'The stream or file "app.log" could not be opened: failed to open stream: Permission denied' in /Users/name/Website2/BuildingWebsiteswithPHP2/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php:87 Stack trace: #0 /Users/name/Website2/BuildingWebsiteswithPHP2/vendor/monolog/monolog/src/Monolog/Handler/AbstractProcessingHandler.php(37): Monolog\Handler\StreamHandler->write(Array) #1 /Users/name/Website2/BuildingWebsiteswithPHP2/vendor/monolog/monolog/src/Monolog/Logger.php(289): Monolog\Handler\AbstractProcessingHandler->handle(Array) #2 /Users/name/Website2/BuildingWebsiteswithPHP2/vendor/monolog/monolog/src/Monolog/Logger.php(341): Monolog\Logger->addRecord(300, 'Foo', Array) #3 /Users/name/Website2/BuildingWebsiteswithPHP2/index.php(8): Monolog\Logger->addWarning('Foo') #4 {main} thrown in /Users/name/Website2/BuildingWebsiteswithPHP2/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php on line 87
這裏是我的index.php文件:
<?php
require __DIR__ . '/vendor/autoload.php';
$log = new Monolog\Logger('name');
$log->pushHandler(new Monolog\Handler\StreamHandler('app.log', Monolog\Logger::WARNING));
$log->addWarning('Foo');
echo "Hello world!";
我已經作曲家安裝在我的項目BuldingWebsites與PHP2。這是否需要安裝在XAMPP中?
更改說他們有權限被拒絕的目錄的權限。 – Ohgodwhy
@Ohgodwhy工作!謝謝。 – Concordance