In actual development, you need to view the structure of the interface return value and the actual data sample. It is troublesome to write the controller and access the url each time.
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:
The code is as follows: |
Copy code |
#! /Usr/bin/env php <? Php Require _ DIR _. '/vendor/autoload. Php '; $ App = require _ DIR _. '/app/bootstrap. Php '; $ App-> 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 (); |