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 Including & Running Slim

Jonathan Prada
Jonathan Prada
7,039 Points

The localhost page isn’t working. localhost is currently unable to handle this request. HTTP ERROR 500. Please Help...

I am using MAMP.

my index.php:

<?php
use \Psr\Http\Message\ServerRequestInterface as Request;
use \Psr\Http\Message\ResponseInterface as Response;

require 'vendor/autoload.php';

$app = new \Slim\App;
$app->get('/hello/{name}', function (Request $request, Response $response) {
$name = $request->getAttribute('name');
$response->getBody()->write("Hello, $name");

return $response;
});
$app->run();

my .htaccess:

RewriteEngine On

# Some hosts may require you to use the RewriteBase directive. # If you need to use the RewriteBase directive, it should be the # absolute physical path to the directory that contains this htaccess file. # # RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^ index.php [QSA,L]

my url:

http://localhost:8888/portfolio/index.php/hello/jonathan

I've tried different fixes from across the forums, nothing appears to work.

Jonathan Prada
Jonathan Prada
7,039 Points

I fixed it by restarting the mamp server, with the code that was shown on the video. Follow the video directly and then after your .htaccess file restart map and try it again.