Skip to content

Latest commit

 

History

History
68 lines (47 loc) · 1.95 KB

generate-clientfactory.md

File metadata and controls

68 lines (47 loc) · 1.95 KB

Generate a base client factory

To make things a little easier to get started a client factory generator method is available.

vendor/bin/soap-client generate:clientfactory

Usage:
  generate:clientfactory [options]

Options:
      --config=CONFIG   The location of the soap code-generator config file
  -o, --overwrite       Makes it possible to overwrite by default
  -h, --help            Display this help message
  -q, --quiet           Do not output any message
  -V, --version         Display this application version
      --ansi            Force ANSI output
      --no-ansi         Disable ANSI output
  -n, --no-interaction  Do not ask any interactive question
  -v|vv|vvv, --verbose  Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

Options:

The factory will be put in the same namespace and directory as the client, and use the same name as the client, appended by Factory.

Example output:

<?php

namespace App\Client;

use App\Client\MyClient;
use App\Order\OrderClassmap;
use Phpro\SoapClient\Soap\Driver\ExtSoap\ExtSoapEngineFactory;
use Phpro\SoapClient\Soap\Driver\ExtSoap\ExtSoapOptions;

class ClientFactory
{

    public static function factory(string $wsdl) : \App\Client\MyClient
    {
        $engine = ExtSoapEngineFactory::fromOptions(
            ExtSoapOptions::defaults($wsdl, [])
                ->withClassMap(OrderClassmap::getCollection())
        );
        $eventDispatcher = new EventDispatcher();

        return new MyClient($engine, $eventDispatcher);
    }

}

You can then tweak this class to fit your needs.

Here you can find some bookmarks for changing the factory: