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 trial

PHP Building Websites with PHP Dependency Management Namespacing

Sági János
PLUS
Sági János
Courses Plus Student 6,185 Points

Not created the app.txt

I'm not using workspace I'm using my own text editor. So my problem is the app.txt it will not be created. That's why i tried to create it, but does not work either. I'm using Mac OSx Pls send a solution, because i can't go any further. Thank's everything. My error. Fatal error: Uncaught UnexpectedValueException: The stream or file "app.txt" could not be opened: failed to open stream: Permission denied in /Applications/XAMPP/xamppfiles/htdocs/teamtreehouse/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php:107 Stack trace: #0 /Applications/XAMPP/xamppfiles/htdocs/teamtreehouse/vendor/monolog/monolog/src/Monolog/Handler/AbstractProcessingHandler.php(37): Monolog\Handler\StreamHandler->write(Array) #1 /Applications/XAMPP/xamppfiles/htdocs/teamtreehouse/vendor/monolog/monolog/src/Monolog/Logger.php(337): Monolog\Handler\AbstractProcessingHandler->handle(Array) #2 /Applications/XAMPP/xamppfiles/htdocs/teamtreehouse/vendor/monolog/monolog/src/Monolog/Logger.php(392): Monolog\Logger->addRecord(300, 'Foo', Array) #3 /Applications/XAMPP/xamppfiles/htdocs/teamtreehouse/index.php(12): Monolog\Logger->addWarning('Foo') #4 {main} thrown in /Applications/XAMPP/xamppfiles/htdocs/teamtreehouse/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php on line 107

My code :<?php

require __DIR__ . '/vendor/autoload.php';

date_default_timezone_get('Hungary/Budapest');

use Monolog\Logger;
use Monolog\Handler\StreamHandler;

$log = new Logger('name'); 
$log->pushHandler(new StreamHandler('app.txt', Logger::WARNING));
$log->addWarning('Foo');



echo 'Hello World!';

1 Answer

Daniel Marin
Daniel Marin
8,021 Points

That's a permission problem.

So let's say I have a file test.php and the owner username is root and I try to run it from account myaccount, it will not work, you get permission denied. so you need to change ownership with chown example: sudo chown myaccount test.php The same is available for folders.
Search for change permissions articles you will probably find a ton of answers
It may also be something related to chmod so try to change permission: sudo chmod 777 app.txt