Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

PHP Building Websites with PHP Slim Basics & Twig Templates Layouts with Twig

Moises Cano
Moises Cano
2,261 Points

500 Error

I'm using slim 3, and when I try to view a twig page I get, PHP Fatal error: Class 'Slim\View' not found.

2 Answers

Hussein Elhussein
PLUS
Hussein Elhussein
Courses Plus Student 2,982 Points

it is recommended to use Slim 2.6 with this course. to do so add the folllowing line to the composer.json file: "slim/slim": "^2.6", then save it and go to the console and type composer require, then enter, then also enter to download the packages inside the composer.json file using Slim 3 is a lot of hassle because it's missing the view class (which is vendor/slim/slim/slim/view.php)

Kirill Devope
Kirill Devope
11,488 Points

Same problem. Using MAMP.

It's my composer.json

{
    "name": "devope/treehouse-php-websites",
    "authors": [
        {
            "name": "Kirill Devope",
            "email": "mail@devope.ru"
        }
    ],
    "require": {
        "slim/slim": "~2.6",
        "twig/twig": "~1.18",
        "slim/views": "0.1.*"
    }
}