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

Zeljko Porobija
Zeljko Porobija
11,491 Points

Not Found The requested URL /hello/friends was not found on this server.

Well, it's not working. http://port-80-0kc2pzcd7b.treehouse-app.com/hello/friends gives the output "Not found..." etc. (see the title). My code seems just identical to the tutorial's. Any idea? Thnx.

Hello Zeljko, I recently completed this course. Can you please upload your code so I can take a look at it? Thanks.

4 Answers

Zeljko Porobija
Zeljko Porobija
11,491 Points

Ups, sorry, I did it right now.... Thnx for being available.

This sounds like you may not have your files in the correct spot. What is your directory structure?

Zeljko Porobija
Zeljko Porobija
11,491 Points

Here is my index.php

require 'vendor/autoload.php';
date_default_timezone_set( 'Europe/Zagreb');

$app = new \Slim\Slim();

$app->get('/', function() {
  echo 'Hello, this is the home page.';
});

$app->get('/contact', function() {
  echo 'Feel free to contact us';
});

$app->run();
Zeljko Porobija
Zeljko Porobija
11,491 Points

.htaccess (just copied and pasted from teacher's notes)

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [QSA,L]
Zeljko Porobija
Zeljko Porobija
11,491 Points

And composer.json

{
    "name": "slim/slim",
    "type": "library",
    "description": "Slim is a PHP micro framework that helps you quickly write simple yet powerful web applications and APIs",
    "keywords": ["framework","micro","api","router"],
    "homepage": "http://slimframework.com",
    "license": "MIT",
    "authors": [
        {
            "name": "Josh Lockhart",
            "email": "hello@joshlockhart.com",
            "homepage": "https://joshlockhart.com"
        },
        {
            "name": "Andrew Smith",
            "email": "a.smith@silentworks.co.uk",
            "homepage": "http://silentworks.co.uk"
        },
        {
            "name": "Rob Allen",
            "email": "rob@akrabat.com",
            "homepage": "http://akrabat.com"
        },
        {
            "name": "Gabriel Manricks",
            "email": "gmanricks@me.com",
            "homepage": "http://gabrielmanricks.com"
        }
    ],
    "require": {
        "php": ">=5.5.0",
        "pimple/pimple": "^3.0",
        "psr/http-message": "^1.0",
        "nikic/fast-route": "^0.6",
        "container-interop/container-interop": "^1.1"
    },
    "require-dev": {
        "squizlabs/php_codesniffer": "^2.5",
        "phpunit/phpunit": "^4.0"
    },
    "autoload": {
        "psr-4": {
            "Slim\\": "Slim"
        }
    },
    "scripts": {
        "test": [
            "php vendor/bin/phpcs",
            "php vendor/bin/phpunit"
        ],
        "phpunit": "php vendor/bin/phpunit",
        "phpcs": "php vendor/bin/phpcs"
    }
}
Zeljko Porobija
Zeljko Porobija
11,491 Points

It's alright now. No, there wasn't a problem with the directory structure, I've just made a stupid typo in coding. Anyway, thnx for offering your help.