Slim framework access to pysh

Source: Internet
Author: User
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();

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.