Slim framework error: call require '../Slim/Slim/Slim.php';

0

Error creating when calling function Slim.php

Code:

<?php
    require '../Slim/Slim/Slim.php';
    \Slim\Slim::registerAutoloader();
    $app = new \Slim\Slim();
    $app->response()->header('Content-Type', 'application/json;charset=utf-8');
    $app->get('/', function () {
    echo "SlimProdutos";
});

    
asked by anonymous 07.06.2017 / 20:55

1 answer

1

From what I've come to realize, you're making use of the composer!

Then try to load using the autoload of the composer, follow the example below:

<?php
    require_once __DIR__ . '/vendor/autoload.php';
    $app = new \Slim\Slim();
    $app->response()->header('Content-Type', 'application/json;charset=utf-8');
    $app->get('/', function () {
        echo "SlimProdutos";
    });
    
07.06.2017 / 21:58