Download the PHP package ensi/laravel-openapi-server-generator without Composer

On this page you can find all versions of the php package ensi/laravel-openapi-server-generator. 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-openapi-server-generator

Laravel OpenApi Server Generator

Generates Laravel application code from Open Api Specification files

Installation

You can install the package via composer:

composer require ensi/laravel-openapi-server-generator

Next you need to publish config file like this:

php artisan vendor:publish --provider="Ensi\LaravelOpenApiServerGenerator\LaravelOpenApiServerGeneratorServiceProvider"

and configure all the options.

Migrating from version 0.x.x

Delete config/openapi-server-generator.php, republish it using command above and recreate desired configuration.

Basic Usage

Run php artisan openapi:generate-server. It will generate all the configured entities from you OAS3 files.
Override default_entities_to_generate configiration with php artisan openapi:generate-server -e routes,enums
Make output more versbose: php artisan openapi:generate-server -v

Overwriting templates

You can also adjust file templates according to your needs.

  1. Find the needed template inside templates directory in this repo;
  2. Copy it to to resources/openapi-server-generator/templates directory inside your application or configure package to use another directory via extra_templates_path option;
  3. Change whatever you need.

Existing entities and generators

'routes' => RoutesGenerator::class

Generates laravel route file (route.php) for each endpoint in oas3->paths
The following extension properties are used by this generator:

route.php file IS overriden with each generation.
You should include it in your main route file like that:

'controllers' => ControllersGenerator::class

Generates Controller class for each non-existing class specified in x-lg-handler
Supports invocable Controllers.
If several openapi paths point to several methods in one Controller/Handler then the generated class includes all of them.
If a class already exists it is NOT overriden.
Controller class IS meant to be modified after generation.

'requests' => RequestsGenerator::class

Generates Laravel Form Requests for DELETE, PATCH, POST, PUT paths
Destination must be configured with array as namespace instead of string.
E.g.

This means "Get handler (x-lg-handler) namespace and replace Controllers with Requests in it"
Form Request class IS meant to be modified after generation. You can treat it as a template generated with php artisan make:request FooRequest
If the file already exists it IS NOT overriden with each generation.

Form Request class name is ucFirst(operationId). You can override it with x-lg-request-class-name
You can skip generating form request for a give route with x-lg-skip-request-generation: true directive.

When generating a request, the Laravel Validation rules for request fields are automatically generated.
Validation rules generate based on the field type and required field.
For fields whose values should only take the values of some enum, you must specify the x-lg-enum-class option. E.g.: x-lg-enum-class: 'CustomerGenderEnum'.

'enums' => EnumsGenerator::class

Generates Enum class only for enums listed in oas3->components->schemas.
Your need to specify x-enum-varnames field in each enum schema. The values are used as enum constants' names.
Destination directory is cleared before generation to make sure all unused enum classes are deleted.
Enums generator does NOT support allOf, anyOf and oneOf at the moment.

'pest_tests' => PestTestsGenerator::class

Generates Pest test file for each x-lg-handler
You can exclude oas3 path from test generation using x-lg-skip-tests-generation: true.
If a test file already exists it is NOT overriden.
Test file class IS meant to be modified after generation.

'resources' => ResourcesGenerator::class

Generates Resource file for x-lg-handler
Resource properties are generated relative to field in response, which can be set in the config

You can also specify response_key for resource: add x-lg-resource-response-key: data in object.
When specifying response_key, you can use the "dot" syntax to specify nesting, for example data.field
You can exclude resource generation using x-lg-skip-resource-generation: true in route.
You can rename resource Class using x-lg-resource-class-name: FooResource in resource object or properties object.
If a resource file already exists it is NOT overridden.
Resource file contains a set of fields according to the specification. You also need to specify mixin DocBlock to autocomplete resource.

'policies' => PoliciesGenerator::class

Generates Laravel Policies for routes. Destination must be configured with array as namespace instead of string. E.g:

Contributing

Please see CONTRIBUTING for details.

Testing

  1. composer install
  2. npm i
  3. composer test

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

License

The MIT License (MIT). Please see License File for more information.


All versions of laravel-openapi-server-generator with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
devizzent/cebe-php-openapi Version ^1.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 ensi/laravel-openapi-server-generator contains the following files

Loading the files please wait ....