Download the PHP package cofa/laravel-api-docs without Composer

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

Laravel API Docs

CI

Zero-config API documentation for Laravel, built on the OpenAPI 3.1 standard and rendered as Blade views inside your own project.

Point it at an application and it reads the whole API — however the project is organised — then compiles what it found into an OpenAPI document and renders that document as a searchable reference page with headers, parameters, request bodies, expected responses, code samples and an in-page request console.

It also remembers: every generation is compared against the last one, so each endpoint carries a timeline of what changed about it and when.

Then open /api/documentation.


Why it works on any project layout

The scanner reads Laravel's route collection, not your directory tree. By the time it runs, every route is registered — whether it came from routes/api.php, a module's service provider, a package, an invokable controller or a closure. Nothing has to be moved, renamed or annotated.

From each route it then works backwards through the code that handles it:

What you get Where it comes from
Method, URI, name, middleware, handler the route itself
Group, summary, description @group / docblock / #[ApiGroup] / controller name
URL parameters URI placeholders, where() constraints, route model binding, action type hints
Body parameters the form request's rules(), or $request->validate([...]) / Validator::make() inside the action
Query parameters $request->query(), input(), boolean(), integer()… plus paginate() detection
Types, constraints, enums, examples the validation rules, including Rule::in(), Rule::enum(), Password::min()
Headers configured defaults, auth middleware, #[ApiHeader], @header
Authentication auth middleware, @authenticated, #[Authenticated]
Success responses API resources (followed into nested resources), models, response()->json(), @response
Error responses auth (401), authorization (403), model binding (404), validation (422), throttling (429), abort()
Change history the diff between this generation and the last recorded snapshot
Tenant scoping the active tenant, for per-tenant documents, history and cache

Rules are read by instantiating the form request when that is safe, and by parsing the source with nikic/php-parser when it is not — so rules that depend on runtime state still get documented. An action the generator cannot read is reported, never fatal: the rest of the API is still documented.

OpenAPI is the source of truth

The scan result is compiled into an OpenAPI 3.1 document, and the Blade UI renders that document. That means:

Nothing OpenAPI reserves is lost either: Accept, Content-Type and Authorization stay out of parameters (as the specification requires) but are kept on the operation under x-headers, alongside x-controller, x-middleware and x-route-name.

Endpoint history

Every api-docs:generate compares the new document against the last recorded snapshot and stores the difference as a revision. The page then shows a changelog of recent revisions, and each endpoint carries its own timeline:

It tracks summaries and descriptions, grouping, deprecation, authentication, path/query/header parameters, request body fields (nested ones included), response status codes and response body fields — reporting each one as a sentence rather than a JSON diff. Changes that can break an existing client (a removed endpoint or field, a newly required field, newly required auth) are flagged as breaking.

The record lives in resources/views/vendor/api-docs/history.json. Commit it: that is what makes the timeline survive across environments and deployments. Configure retention and display under api-docs.history, or set history.enabled to false to turn the whole feature off.

Multi tenancy

A multi tenant application serves the same routes from many contexts, so the artefacts have to be scoped per tenant. Put a {tenant} placeholder anywhere in the config and it is replaced with the current tenant key:

Each tenant then gets its own document, its own change history and its own cache entry — the cache key is scoped automatically, because sharing one cached document between tenants would serve one tenant's documentation to another. The tenant key is sanitised before it reaches a path or a cache key, so a key like ../../etc cannot escape its directory.

The tenant is detected automatically for stancl/tenancy (the tenant() helper) and spatie/laravel-multitenancy (Tenant::current()). For anything else, point the resolver at a closure or an invokable class:

Resolution happens on every read rather than once at boot, so a console command that walks through tenants (php artisan tenants:run api-docs:generate) writes each tenant's documentation to its own place. When no tenant is active the central_key (central by default) is used instead.

On the page itself, the code samples and the try-it console follow the host the documentation is being viewed on, so a tenant sees its own domain rather than a single configured URL. Set tenancy.follow_request_host to false to use the configured base_url instead. For domain based tenancy the docs route accepts a Laravel domain pattern:

If your configuration is cached, remember that a closure resolver cannot be serialised — use the invokable class form.

Caching

Caching is off by default: the documentation is scanned live, which is what you want in development. Turn cache.enabled on in production and refresh it during deployment.

The documentation never depends on the cache being healthy. If the store cannot be reached — a database cache driver pointed at a connection whose cache table was never migrated, a Redis that is down — the page falls back to a live scan and the commands report the reason instead of failing. With caching off, the cache store is not touched at all.

If your default store is somewhere the documentation should not rely on (a tenant database, for instance), point it somewhere else:

Installation

The service provider is auto-discovered. Publish the config if you want to tune it:

Usage

You do not have to run anything at all in development: the route renders the documentation live from the current code. Enable api-docs.cache.enabled in production and refresh it during deployment.

The generated Blade files are ordinary views. Edit them and they stay edited — api-docs:generate never overwrites an existing template unless you pass --force.

Documenting by hand

Everything is inferred, but anything can be overridden. Both a docblock and an attribute syntax are available; explicit documentation always wins.

The same thing with attributes:

If both a docblock tag and an attribute describe the same parameter on the same action, the attribute's value wins. Precedence is decided field by field, not source by source: if the docblock documents email and an attribute documents notify, both apply, and an attribute that names a parameter without saying anything about its type leaves the documented type alone. The same rule covers the summary, description, group, deprecation, authentication, headers and responses.

Nothing is overruled quietly. api-docs:generate reports every disagreement:

Teams that would rather have documentation drift break the build than resolve itself can set strict_precedence to true, which makes api-docs:generate fail on a disagreement and write nothing. The documentation page is never affected either way — drift should fail a build, not take the docs down.

Hide something with #[HideFromDocs] or @ignore on the action or the whole controller.

Form requests can describe their own fields, and the descriptions are merged with the ones derived from the rules:

Configuration

config/api-docs.php covers:

The page itself

Testing

291 tests cover the rule parser, docblock parser, parameter nesting, schema generation, the spec reader (including third-party OpenAPI documents), code samples, the change differ and history store, tenant resolution and scoping, degraded cache stores, docblock/attribute precedence, the scanner end to end, the generated document, the rendered page and every console command.

CI runs the suite on every supported combination — PHP 8.2, 8.3 and 8.4 against Laravel 12 and 13 — on each push and pull request.

Requirements

The code itself runs unchanged on Laravel 10 and 11 — the suite passes against both — but those branches are past their security support window, so a current Composer refuses to install them and they are not listed as supported. If you are pinned to one of them, require this package with your own advisory exception (policy.advisories.block) and it will work.

License

MIT.


All versions of laravel-api-docs with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
ext-json Version *
illuminate/console Version ^12.0|^13.0
illuminate/routing Version ^12.0|^13.0
illuminate/support Version ^12.0|^13.0
nikic/php-parser Version ^4.18|^5.0
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 cofa/laravel-api-docs contains the following files

Loading the files please wait ...