Yii2 using zircote/swagger-php for swagger construction

Source: Internet
Author: User
Tags yii

The blog on the website about Chinese is a lot of things, and many of them have wasted a lot of my time.

And then just get ready to bite. Read the English Documentation:

https://packagist.org/packages/zircote/swagger-php

To build the site, using the Yii2 2.0.12

Installing with composer

Composer require zircote/swagger-php


and then download Swagger-ui. This is primarily a client that does a swagger debug, and does not interact with the backend, mainly through a JSON to initialize the work

Https://github.com/swagger-api/swagger-ui

And then to the inside of the dist/index.html to modify the JSON file reference, I put this client into a separate domain name, and then write a method in Yii to generate a JSON

Define (' Api_host ', (yii_env = = = ' Dev ')? ' New.rprise.wd.com ': ' test.com ');
$b 2broot = Yii::getalias (' @rprise ');
$swagger = \swagger\scan ($b 2broot);
echo $swagger; exit;

Then point the dist/index.html file to this file route

Build a System
Const UI = Swaggeruibundle ({
URL: "HTTP://NEW.RPRISE.WD.COM/USER/GENSWG",//Modify this location
dom_id: ' #swagger-ui ',
Deeplinking:true,


In order to avoid misleading everyone, or not to say, and finally hope that we still see more official documents

HTTPS://GITHUB.COM/ZIRCOTE/SWAGGER-PHP/BLOB/HEAD/DOCS/GETTING-STARTED.MD//write the code's annotation specification here

Look at this when you see one Leng Leng

https://bfanger.nl/swagger-explained/#schemaObject

Building code generation at the outset may result in an error

Like what

@SWG/info not fount the kind is because did not write the comment, in short patient, believes the official website document, has the question message to discuss

Yii2 using zircote/swagger-php for swagger construction

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.