P
P
Padre2018-02-03 07:30:49
Slim Framework
Padre, 2018-02-03 07:30:49

How to call your class in Slim Framework?

$app->get('/', function (Request $request, Response $response, array $args) {
    $response->getBody()->write("Main"); // работает

    $mod = \Model\MyModel();
    $mod->go();

    return $response;
});

Class autoloading via Composer enabled:
"autoload": {
      "psr-4": {
      	"Model\\": "model/"
      }
  }

There is an error on the screen, and in the error both the namespace and the class name are written in lowercase letters, and I had capital letters in the name:
Fatal error: Call to undefined function model\mymodel() in

I tried to call the class and namespace lowercase - it did not help. But still I wonder why, does he convert them somewhere inside?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey delphinpro, 2018-02-03
@yii16

So you connect a class or a function?
Maybe they just forgot new?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question