Integrate Swagger plug-ins into the ThinkPHP framework

WBOY
Release: 2016-08-18 09:15:57
Original
1794 people have browsed it

I installed the tutorial on this website to synthesize the swagger plug-in into ThinkPHP; https://github.com/fengdeqiao...
I found that this tutorial has many pitfalls, and errors will occur if you are not careful. I have now reached the fourth step of synthesis:

**

Step 4: Use swagger-php in thinkphp

**

If we have to manually execute the third step of the code every time we modify the API, which is a bit cumbersome, then we will write a method in the controller, execute it automatically every time we access swagger-ui, and then jump to the foreground swagger in the interface.

Note: Add require './vendor/autoload.php' to the thinkphp entry file index.php;

The following are the methods in the controller

$path = 'E:wamp64wwwtp'; //Which folder do you want the comments under 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 when calling the scan() function, an error is reported, saying Class 'SwaggerStaticAnalyser' not found
Can any expert tell me how to modify it?

Reply content:

I installed the tutorial on this website to synthesize the swagger plug-in into ThinkPHP; https://github.com/fengdeqiao...
I found that this tutorial has many pitfalls, and errors will occur if you are not careful. I have now reached the fourth step of synthesis:

**

Step 4: Use swagger-php in thinkphp

**

If we have to manually execute the third step of the code every time we modify the API, which is a bit cumbersome, then we will write a method in the controller, execute it automatically every time we access swagger-ui, and then jump to the foreground swagger in the interface.

Note: Add require './vendor/autoload.php' to the thinkphp entry file index.php;

The following are the methods in the controller

$path = 'E:wamp64wwwtp'; //Which folder do you want the comments under 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 when calling the scan() function, an error is reported, saying Class 'SwaggerStaticAnalyser' not found
Can any expert tell me how to modify it?

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

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!