PHP code example of waffler / waffler-laravel

1. Go to this page and download the library: Download waffler/waffler-laravel library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

waffler / waffler-laravel example snippets


'clients' => [
    App\Clients\MyClientInterface::class => [/* GuzzleHttp options */],
],

'aliases' => [
    App\Clients\MyClientInterface::class => 'my-custom-alias',
],

'global_options' => [/* GuzzleHttp options */],

'singletons' => [
    App\Clients\MyClientInterface::class,
],

'auto_generated_clients' => [
    'App\Clients\FooBarClientInterface',
],

'code_generation' => [
    'namespace' => 'App\\Clients',
    'openapi_files' => []
]

'namespace' => 'App\\Clients',

'openapi_files' => [
    // Example 1:
    resource_path('swagger/my-swagger-file.json'),
    
    // Example 2 with custom options:
    resource_path('swagger/my-swagger-file.json') => [
        'namespace' => 'MyCustomApi',
        'namespace_options' => [
            'base_uri' => env('MY_CUSTOM_API_BASE_URI')
        ],
        'ignore' => [
            'parameters' => [
                'header' => ['X-SOME-HEADER-NAME']
            ]
        ]
    ]
],

'namespace' => 'App\\Clients',
'openapi_files' => [
    resource_path('swagger/my-swagger-file.json') => [
        'namespace' => 'MyCustomApi', // Will be converted to App\Clients\MyCustomApi
    ],
],

'namespace' => 'App\\Clients',
'openapi_files' => [
    resource_path('swagger/my-swagger-file.json') => [
        'namespace' => 'MyCustomApi',
        'spec_type' => 'swagger',
    ],
],

'openapi_files' => [
    resource_path('swagger/my-swagger-file.json') => [
        'namespace' => 'MyCustomApi',
        'namespace_options' => [
            'base_uri' => env('MY_CUSTOM_API_BASE_URI')
        ],
    ],
],

'openapi_files' => [
    resource_path('swagger/my-swagger-file.json') => [
        'ignore' => [
            'parameters' => [
                'header' => ['Authorization']
            ]
        ],
        'namespace_options' => [
            'headers' => [
                'Authorization' => env('MY_CLIENT_API_KEY')
            ],
        ],
    ],
],



use Waffler\Attributes\Request\HeaderParam;

interface MyClientInterface
{
    public function users(#[HeaderParam('Authorization')] string $authorization): array;
}



use Waffler\Attributes\Request\HeaderParam;

interface MyClientInterface
{
    public function users(): array;
}

'openapi_files' => [
    resource_path('swagger/my-swagger-file.json') => [
        'auto_bind' => false
    ],
],