Download the PHP package jkbennemann/laravel-api-documentation without Composer

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

Laravel API documentation

Latest Version on Packagist Total Downloads

This library is currently in an alpha phase

  • still under development
  • versions are not stable
  • breaking changes can occur

This is an opinionated package to generate API documentation for Laravel applications. They key focus is to remove the need to manually write documentation and keep it up to date by generating it from the code.

Installation

You can install the package via composer:

You can publish the config file with:

By default it will set the settings to the following:

Linking the storage's public directory

The package will store the generated documentation at the defined disk.
By default it will use the public disk to store the documentation. For the default Laravel disk of public you'd need to link the storage folder to make it accessible by running:

This will ensure that the generated documentation is accessible.
When generating the documentation the package (by default) will store the documentation at storage/app/public/api-documentation.json.

In order for this to work you need to have the public disk configured in your config/filesystems.php.
This should be already configured by default by your application.

As the documentation is stored in the storage folder of your application which by default will not be added to the VCS
it is needed to explicitly exclude the api-documentation.json from your storage/app/public/.gitignore file.

If you want to make the documentation public by default, without the need to link the storage folder, you can:

  1. Add a dedicated disk configuration for the documentation to config/filesystems.php (Recommended)
  2. Adjust the default disk configuration to not use the storage_path() (Not recommended)

and then using the disk public_exposed in the config/laravel-api-documentation.php file.

Useful tips

If you want to automatically re-generate the documentation all the time, consider to add a git hook to your repository.
This way you allow the documentation to be kept up-to-date, every time you push changes to your repository.

Generating the documentation

bash php artisan documentation:generate json { "scripts": { "documentation:generate": [ "@php artisan documentation:generate" ] } } json { //... "\/login": { "post": { "tags": [ "Authentication" ], //... } } } json { //... "\/login": { "post": { "summary": "Login a user", //... } } } json { //... "\/login": { "post": { "description": "Logs an user in.
This route requires a valid email and password.", //... } } } json { //... "\/login": { "post": { "externalDocs": { "url": "https://example.com/docs", "description": "External documentation" } //... } } } json { //... "\/login": { "post": { //... "responses": { "200": { "description": "Logged in user information", "headers": { "X-Token": { "description": "Token for the user to be used to issue API calls", "schema": { "type": "string" } } }, "content": { "application\/json": { "schema": { //data of the UserResource.php } } } }, "401": { "description": "Failed Authentication", "headers": {}, "content": { "application\/json": { "schema": { "type": "object", "properties": { "error": { "type": "string" } } } } } } } //... } } }



### Request/Resource attributes

For request or resource classes the same attributes can be used as for the routes, except for the `Tag` attribute.  
In addition to that the following attributes are available:

#### 1. Parameter
This attribute can be used to specify additional information about a parameter.

Available parameters:
- (required) `name` (string) - The name of the parameter
- `required` (boolean) - Whether the parameter is required or not; *default:`false`*
- `description` (string) - A description of the parameter; *default:`''`*
- `type` (string) - The type of the parameter; *default:`'string'`*
- `format` (string) - The format of the parameter, considered as the sub-type as of OpenAPI; *default:`null`*
- `example` (mixed) - An example value for the parameter; *default:`null`*
- `deprecated` (boolean) - Whether the parameter is deprecated or not; *default:`false`*

## Roadmap
- [ ] Add support providing examples for request
- [ ] Add support for handling inline controller validation rules
- [ ] Adjusting the logic to determine the response structure with its types and formats correctly
- [ ] Option to customize the location of the generated documentation file
  -  [ ] Support for external storages (eg. Github Link, S3 Bucket, ...)
- [ ] ...

## Security Vulnerabilities

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

## Credits

- [Jakob Bennemann](https://github.com/jkbennemann)
- [All Contributors](../../contributors)

## License

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

All versions of laravel-api-documentation with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
illuminate/contracts Version ^10.0 || ^11.0 || ^12.0
nikic/php-parser Version ^5.3
php-openapi/openapi Version ^2.0
spatie/laravel-package-tools Version ^1.16
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 jkbennemann/laravel-api-documentation contains the following files

Loading the files please wait ....