The slim framework is connected to pysh because the interface return value structure and actual data sample need to be viewed during actual development. it is troublesome to write the controller every time and then access the url.
Therefore, it is extremely convenient to call the model and function defined in the website application in an interactive way like php-.
The directory structure is as follows:
app/public/tinker
What is the logical implementation of an app for a website?
Under public, there is an index. php entry for the website.
Tinker is the file that we need to access pysh to implement REPL.
Because the PATH_INFO value is required in the Slim, but this value does not exist when running the command line, you need to mock it in the code. the code is as follows:
#!/usr/bin/env php
environment = \Slim\Environment::mock([ 'PATH_INFO' => '/playground']);$app->notFound(function () use ($app) { $path = $app->environment['PATH_INFO']; echo "Cannot route to $path" . PHP_EOL; $app->stop();});$app->error(function (\Exception $e) use ($app) { echo $e . PHP_EOL; $app->stop();});$app->any('/playground', function () { $config = new \Psy\Configuration([ 'tabCompletion' => true, 'tabCompletionMatchers' => [ new \Psy\TabCompletion\Matcher\ClassNamesMatcher, new \Psy\TabCompletion\Matcher\ClassMethodsMatcher, new \Psy\TabCompletion\Matcher\ClassAttributesMatcher, new \Psy\TabCompletion\Matcher\FunctionsMatcher, ], ]); $shell = new \Psy\Shell(); $shell->run();});$app->run();