Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialJose Reyna
13,532 PointsGetting an error when previewing index.php
I edited the index.php file following along with Hampton but when I went to preview the file I received a server error. Perhaps I have a syntax error I am not seeing. My snapshopt is below.
3 Answers
amadeo brands
15,375 PointsHaving also a problem here.
<?php
require __DIR__ . '/vendor/autoload.php';
date_default_timezone_set("Europe/Amsterdam");
$log = new Monolog\Logger('name');
$log->pushHandler(new Monolog\Handler\StreamHandler('app.txt', Monolog\Logger::WARNING));
$log->addWarning('Foo');
echo "Hello world Amadeo is a developer!";
Check the error:
Fatal error: Uncaught UnexpectedValueException: The stream or file "app.txt" could not be opened: failed to open stream: Permission denied in /home/treehouse/workspace/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php:87 Stack trace: #0 /home/treehouse/workspace/vendor/monolog/monolog/src/Monolog/Handler/AbstractProcessingHandler.php(37): Monolog\Handler\StreamHandler->write(Array) #1 /home/treehouse/workspace/vendor/monolog/monolog/src/Monolog/Logger.php(336): Monolog\Handler\AbstractProcessingHandler->handle(Array) #2 /home/treehouse/workspace/vendor/monolog/monolog/src/Monolog/Logger.php(391): Monolog\Logger->addRecord(300, 'oh Noes.', Array) #3 /home/treehouse/workspace/index.php(9): Monolog\Logger->addWarning('oh Noes.') #4 {main} thrown in /home/treehouse/workspace/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php on line 87
amadeo brands
15,375 PointsVerry strange just deleted the workspace and restarted and all seems to be working
Jaymes Young
36,282 PointsThe solution I found was similar, simply delete the app.txt file and it seems to work again. A new one will be created when you run the program again.