Generate a PHP client for an OPENAPI specification
composer require --dev vanengers/php-openapi-client-generator
OPENAPI=http://127.0.0.1:8000/docs.json NAMESPACE=VendorName\\PackageName\\Generated OUTPUT_DIR=src/Generated ./bin/api-client-generator generate
OPENAPI=http://127.0.0.1:8000/docs.json
NAMESPACE=VendorName\\PackageName\\Generated
OUTPUT_DIR=src/Generated
./bin/api-client-generator generate
You will need to finish the implementation of the client yourself. This is for generation of the login methods, which may differ per API. And you will need to add the correct namespace to the generated classes. You can also add your own methods to save and retrieve a Saved Token.
public function login()
{ ... }
callable $saveToken = fn (string $token) => saveInterally($token);