Download the PHP package alexcicioc/swagger-router without Composer

On this page you can find all versions of the php package alexcicioc/swagger-router. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package swagger-router

swagger-router

Swagger Router is a library that speeds up API development while having it documented.

It uses a json spec file compatible with OpenAPI specification 2.0 and should support most of the features but if you find something missing feel free to open a pull request or an issue.

Install via composer:

composer require alexcicioc/swagger-router

Using swagger-router to bootstrap the API:

Defining the endpoints using swagger

You'll need to define your API endpoints in the swagger spec. Here's a simple example you can use (it's in yaml for readability but should be converted to json):

Recommendation: You can use Swagger Editor to safely modify the spec then click on the File menu and "Convert and save to JSON".

Redirecting the requests

You'll need to redirect everything to index.php. If you're using apache you can add this to your .htaccess file

Bootstrapping the app using swagger-router

In index.php you'll have to build the SwaggerRouter instance. You can use this sample:

Creating a controller

Previously in the spec we added these lines:

This tells swagger-router to search for the Courses controller and call the method getCourses

Sample spec:

https://github.com/alexcicioc/swagger-router/blob/master/sample-spec.json

Laravel compatibility

Swagger Router's middlewares are not compatible with Laravel's yet, however there's a workaround this.

Here's a sample Laravel middleware that calls the swagger router (not properly tested, may have some side effects):


All versions of swagger-router with dependencies

PHP Build Version
Package Version
Requires php Version >=7.2.0
guzzlehttp/psr7 Version ^1.5
league/oauth2-server Version ^7.4
ext-json Version *
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package alexcicioc/swagger-router contains the following files

Loading the files please wait ....