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 Slim Basics & Twig Templates Routing For Our Project

Using PHPStorm

I can not get this to echo to the browser. I am running phpstorm 9.0 instead of work spaces. I have composer and slim installed. Built that .htaccess file but still getting 404 error. Any help is greatly appreciated.

9 Answers

I have no idea about PHPStorm. But I do know if you have the file in a subfolder in the folder you typically put your projects, you should use http://localhost/projectFolder.

After some time i have finally figured it out. Project folder has to be in the /xampp/htdocs/[your folder]. Plus in address bar i had to remove localhost:63342/simple_web/index.php/hello/chris to localhost/simple_web/index.php/hello/chris and it works. Thank you ted for your earlier post it pointed me in the right direction.

Andreas Bom
Andreas Bom
3,441 Points

I think you'll find the answer here; http://stackoverflow.com/questions/19607345/previewing-a-slim-framework-project-with-phpstorm7-results-page-not-found-while

Instead of running your project from phpstorm, run it from xampp (I had the same problem. I tried the solution in the link, and it didn't work. Instead I start my project from Easyphp (simular to xampp) and it works)

jason chan
jason chan
31,009 Points

do you have apache web server working? Are you browsing via localhost?

localhost

Without code there is no real way to answer this. Have you tried a simple php file with only an echo and tried to preview it? If so, did it work? If not, then there is a problem with your setup. If that worked and your more detailed code does not, it is a coding problem that we can try to help with if you post the code.

Simple page works fine. I also tried downloading the treehouse files and running it. The 404 Not found with the The page you are looking for could not be found. Check the address bar to ensure your URL is spelled correctly. If all else fails, you can visit our home page at the link below. Visit the Home Page

then when i add the /hello/name in the address bar i get 404 Not found that's why i was thinking it was setting or something in phpstorm.

D:\xampp\php\php.exe D:\PhpstormProjects\web_simple\index.php

Fatal error: Uncaught exception 'ErrorException' with message 'Undefined index: REQUEST_METHOD' in D:\PhpstormProjects\web_simple\vendor\slim\slim\Slim\Environment.php:124
Stack trace:
#0 D:\PhpstormProjects\web_simple\vendor\slim\slim\Slim\Environment.php(124): Slim\Slim::handleErrors(8, 'Undefined index...', 'D:\\PhpstormProj...', 124, Array)
#1 D:\PhpstormProjects\web_simple\vendor\slim\slim\Slim\Environment.php(76): Slim\Environment->__construct()
#2 D:\PhpstormProjects\web_simple\vendor\slim\slim\Slim\Slim.php(159): Slim\Environment::getInstance()
#3 D:\PhpstormProjects\web_simple\vendor\slim\slim\Slim\Helper\Set.php(228): Slim\Slim->Slim\{closure}(Object(Slim\Helper\Set))
#4 D:\PhpstormProjects\web_simple\vendor\slim\slim\Slim\Helper\Set.php(88): Slim\Helper\Set->Slim\Helper\{closure}(Object(Slim\Helper\Set))
#5 D:\PhpstormProjects\web_simple\vendor\slim\slim\Slim\Helper\Set.php(185): Slim\Helper\Set->get('environment')
#6 D:\PhpstormProjects\web_simple\vendor\slim\slim\Slim\Slim.php(191): Slim\Helper\Set->offsetGet in D:\PhpstormProjects\web_simple\vendor\slim\slim\Slim\Environment.php on line 124

Process finished with exit code 255

Edited to format error code.

I meant the actual php code, not the error code.

Works fine if you don't run it from PHPstorm thank you for your help.