Assemble the swagger plugin into the thinkphp frame

Source: Internet
Author: User
Tags autoload
I install this site tutorial to the swagger plug-in synthesis into thinkphp; Https://github.com/fengdeqiao ...
Found this tutorial a lot of pits, accidentally will be wrong. I have now synthesized to the fourth step:

**

Fourth step: Use swagger-php in thinkphp

**

If we modify the API every time, but also to manually execute the third step of the code, some cumbersome, then we will write a method in the controller, each access to Swagger-ui automatically, and then jump to the foreground swagger interface.

Note: Add require './vendor/autoload.php ' to Thinkphp's entry file index.php;

Here's how it's inside the controller.

$path = ' E:WAMP64WWWTP '; Which folder do you want the following comment to generate the corresponding API document
$swagger = Swaggerscan ($path);
Header (' Content-type:application/json ');
Echo $swagger;
$swagger _json_path = $path. ' /swagger-docs/swagger.json ';
$res = file_put_contents ($swagger _path, $swagger);
if ($res = = True) {
$this->redirect (' http://localhost/swagger-ui/d ... ');
}

But call the scan () function to error, saying that Class ' swaggerstaticanalyser ' not found
Which master can tell me how to modify!

Reply content:

I install this site tutorial to the swagger plug-in synthesis into thinkphp; Https://github.com/fengdeqiao ...
Found this tutorial a lot of pits, accidentally will be wrong. I have now synthesized to the fourth step:

**

Fourth step: Use swagger-php in thinkphp

**

If we modify the API every time, but also to manually execute the third step of the code, some cumbersome, then we will write a method in the controller, each access to Swagger-ui automatically, and then jump to the foreground swagger interface.

Note: Add require './vendor/autoload.php ' to Thinkphp's entry file index.php;

Here's how it's inside the controller.

$path = ' E:WAMP64WWWTP '; Which folder do you want the following comment to generate the corresponding API document
$swagger = Swaggerscan ($path);
Header (' Content-type:application/json ');
Echo $swagger;
$swagger _json_path = $path. ' /swagger-docs/swagger.json ';
$res = file_put_contents ($swagger _path, $swagger);
if ($res = = True) {
$this->redirect (' http://localhost/swagger-ui/d ... ');
}

But call the scan () function to error, saying that Class ' swaggerstaticanalyser ' not found
Which master can tell me how to modify!

No https://github.com/TIGERB/swa ...

  • Related Article

    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.