Download the PHP package laxity7/laravel-swagger without Composer

On this page you can find all versions of the php package laxity7/laravel-swagger. 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 laravel-swagger

Laravel Swagger

Laravel Swagger scans your Laravel project's endpoints and auto generates a Swagger 2.0 documentation for you.

Total Downloads Latest Stable Version License

About

Laravel Swagger works based on recommended practices by Laravel. It will parse your routes and generate a path object for each one. If you inject Form Request classes in your controller's actions as request validation, it will also generate the parameters for each request that has them. For the parameters, it will take into account whether the request is a GET/HEAD/DELETE or a POST/PUT/PATCH request and make its best guess as to the type of parameter object it should generate. It will also generate the path parameters if your route contains them. Finally, this package will also scan any documentation you have in your action methods and add it as summary and description to that path, along with any appropriate annotations such as @deprecated.

One thing to note is this library leans on being explicit. It will choose to include keys even if they have a default. For example, it chooses to say a route has a deprecated value of false rather than leaving it out. The file can be easily cleaned up afterward if the user chooses to leave out the defaults.

Installation

The package can easily be installed by running composer require laxity7/laravel-swagger in your project's root folder.

This will register the artisan command that will be available to you.

You can also override the default config provided by the application by running php artisan vendor:publish --provider "Laxity7\LaravelSwagger\SwaggerServiceProvider" in your projects root and change the configuration in the new config/laravel-swagger.php file created.

Usage

Write code as you normally would, using the recommended practices by Laravel. This package will scan your routes and controllers and generate the documentation for you. Generating the swagger documentation is easy, simply run php artisan laravel-swagger:generate in your project root.

Keep in mind the command will simply print out the output in your console. If you want the docs saved in a file, you can reroute the output like so: php artisan laravel-swagger:generate -o swagger.json

If you wish to generate docs for a subset of your routes, you can pass a filter using --filter, for example: php artisan laravel-swagger:generate --filter="/api"

By default, laravel-swagger prints out the documentation in json format, if you want it in YAML format, you can override the format using the --format (-f) flag. Make sure to have the yaml extension or symfony/yaml package installed if you choose to do so. By default, format options are: json or yaml. You can add your own format by adding a new class that implements the Laxity7\LaravelSwagger\Generators\FormatGenerator interface and add it to the 'formats' array in the config/laravel-swagger.php file.

By default, prints out the documentation to the console, if you want it in a file, you can override the output using the --output (-o) flag.

Usage in code

You can also use the package in your code by using the Laxity7\LaravelSwagger\Generator class.

Customization

Custom request generators

You can add your own custom request generators to the package by adding a new class that implements the Laxity7\LaravelSwagger\Parsers\Requests\Generators\ParameterParser interface and add it to the 'parameterParsers' array in the config/laravel-swagger.php file.

For example, let's say you have a custom request generator class called App\Swagger\CustomBodyParameterGenerator. You can add it to the 'parameterParsers' array like this:

Example

Your route file might look like this:

Your sample controller might look like this:

And the FormRequest class might look like this: The field description is taken from the property docblock or the property annotation from the class docblock.

Running php artisan swagger:generate -o swagger.json will generate the following file:


All versions of laravel-swagger with dependencies

PHP Build Version
Package Version
Requires phpdocumentor/reflection-docblock Version ^5.3
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 laxity7/laravel-swagger contains the following files

Loading the files please wait ....