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 Autoloading

Juliette Tworsey
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Juliette Tworsey
Front End Web Development Techdegree Graduate 32,425 Points

Missing app.txt file-

Hi,

After saving and refreshing in the workspace there is still no app.txt file generated.

Here is my code:

<?php

require 'vendor/autoload.php'; date_default_timezone_set('America/Chicago');

$log = new Monolog\Logger('name');

$log->pushHandler(new Monolog\Handler\StreamHandler('app.txt', Monolog\Logger::WARNING));

$log->addWarning('Foo');

echo 'Hello World!';

What could be wrong?

Thanks-

5 Answers

Alena Holligan
STAFF
Alena Holligan
Treehouse Teacher

Juliette Tworsey You're code seems to work for me now, workspaces may have had a problem.

If you're still having issues, check out https://teamtreehouse.com/community/just-making-sure-my-codes-okay-as-i-am-getting-a-server-error

Then if you are still having issues after that, make a snapshot of the space by clicking on the camera icon and following the steps until you get a url you can post here. Then I can fork your space and work with the same file.

Juliette Tworsey
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Juliette Tworsey
Front End Web Development Techdegree Graduate 32,425 Points

Thanks for clarifying that for me Alena!

I will bookmark the Treehouse link that you have provided and I will take a snapshot so that my code can be forked should I run into any issues again.

Cheers:-)

There is a bug in the permissions system. The system wont let the code create the file. I have submitted a bug on this. You basically have to act like it works, after this course you wont need it.

I did this course on my own text editor, but I would be surprised if there is a permissions bug. You can create other files with no problem.

Yeah it's an issue with workspace. You load it up on another system it works.

I just retook the course in Workspaces. My comment about slim above is wrong. You do not need Slim. However, Workspaces does work. If you are not getting your .txt file there is a problem with your process somewhere. Now that I retook it, I remembered that I switched to my text editor because I could not see the .txt file. This time I can and did one thing differently: I refreshed the file tree view in Workspaces. So try these things for troubleshooting:

  1. Do you see a composer.json file? If so, open it and look to see if it says "require": { "monolog/monolog": "^1.14", "slim/slim": "^2.6" } If there is no json file, then composer has not been initialized for the project. Run composer init in the console. If the require is not in the json file, you have not properly installed Monolog.

  2. Do you have a vendor folder? Do you have Monolog in the vendor folder? If you do not have them, there is a problem with your installation and start over. You should have both if step 1 is correct.

  3. Try refreshing your Workspaces file tree by right clicking on the tree and selecting refresh.

  4. If you still have no .txt file, try this code:

<?php
require 'vendor/autoload.php';
date_default_timezone_set('America/Los Angeles');

echo "hello, world ln5";

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

$log->addWarning('Foo');

echo "<br> line 12";

Refresh your file tree. This code worked for me and did the echos. When I first tried it I had some typos in the pushHandler and the first echo worked, but the second did not.

Let me know if you need any more help. If you do, please post a fork snapshot so I can look at the file setup and see if I can make it fun.

Juliette Tworsey
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Juliette Tworsey
Front End Web Development Techdegree Graduate 32,425 Points

Hi Ted,

Thank you so much for taking so much time to help me troubleshoot. After all of that (LOL....or should I say Grrrrrr) I have realized that there is likely an issue with the Workspace refresh function. After refreshing the left hand panel (yesterday) there was no app.txt file generated. Now today (with the same code) the file is there after refreshing!

What text editor do you use? Just curious...

Thanks again:-)

I really like Brackets. http://brackets.io

You did not start Slim.

<?php
require 'vendor/autoload.php';
$app = new \slim\slim();
Rest of code;

This should help.

Your time zone goes before slim

michael7williams
michael7williams
9,638 Points

I'm doing this in my own Linux Ubuntu VirtualBox and was having the same issue.

1st: make sure if you are on windows or linux, that you copy the correct require statement. The linux version is :

require Dir . '/vendor/audoload.php';

2nd.: The real reason I was having the issue was because of permissions. I just set the docroot of this project to 777:

chmod 777 /var/www/whatever your docroot is for your apache server

remember to change that back after.