Create a swoole server

@param  array $config server config
@return \Swoole\Http\Server
323970
public function createServer(array $config)
    {
        // Mark server mode
        define('SERVER_MODE', 'swoole');

        $this->config = $config + [
            'host' => '0.0.0.0',
            'port' => '8000',
            'task_worker_num' => 0,
            'enable_websocket'=> false
        ];

        // Start websocket or http server
        if ( empty($config['enable_websocket']) ) {
            $this->server = new \Swoole\Http\Server($this->config['host'], $this->config['port']);
        } else {
            $this->config['open_http_protocol'] = true;
            $this->server = new \Swoole\WebSocket\Server($config['host'], $config['port'], SWOOLE_PROCESS, SWOOLE_SOCK_TCP);
        }

        $this->server->set($this->config);

        // Show welcome finger
        $this->printServerFinger();

        return $this;
    }
76053
public function createFromConfig(array $config)
    {
        $class = key($config);
        $this->checkMappingIsValid($class);

        return new ClassArgumentObject($this->mapping[$class]->getInstance(), $config[$class]);
    }
329224
public static function factory($config = array())
	{
		$client = new self($config['baseURL'], $config);
		$client->setDefaultOption('headers/Content-Type', 'application/json');
		$client->setDefaultOption('X-Kinvey-API-Version', 2);
		$client->setAuthMode($config['defaultAuthMode']);

		$client = self::registerPlugins($client);

		return $client;
	}
1114148
public function make(array $config)
    {
        Arr::requires($config, ['token']);

        $client = new Client();

        return new BallouGateway($client, $config);
    }
1158059
public static function build(array $config)
    {
        $input = new Input();
        $input->setQuery($_GET)
            ->setPost($_POST)
            ->setCookie($_COOKIE)
            ->setFiles($_FILES)
            ->setServer($_SERVER)
            ->setEnv($_ENV)
            ->setRequest($_REQUEST);

        return new Kernel($input, $config);
    }
540100
public static function create(array $config)
    {
        if (!empty($config['url'])) {
            $config['app_id'] = substr(parse_url($config['url'], PHP_URL_PATH), 6);
            $config['key'] = parse_url($config['url'], PHP_URL_USER);
            $config['secret'] = parse_url($config['url'], PHP_URL_PASS);
            $config['scheme'] = parse_url($config['url'], PHP_URL_SCHEME);
            $config['host'] = parse_url($config['url'], PHP_URL_HOST);
            $config['port'] = parse_url($config['url'], PHP_URL_PORT) ?: $config['port'];
        }

        // For backwards compatibility with deprecated host argument
        if (preg_match('(^(https?://))', $config['host'], $matches)) {
            $config['scheme'] = substr($matches[0], 0, -3);
            $config['host'] = substr($config['host'], strlen($matches[0]));
        }

        return new Pusher(
            $config['key'],
            $config['secret'],
            $config['app_id'],
            [
                'scheme' => $config['scheme'],
                'host' => $config['host'],
                'port' => $config['port'],
                'timeout' => $config['timeout'],
                'cluster' => $config['cluster'],
                'debug' => $config['debug'],
            ]
        );
    }
870154
public static function factory(array $config)
    {
        if ( ! array_key_exists('apiKey', $config)) {
            throw new \Exception('Api factory requires $apiKey parameter.');
        }

        $client = new Client([
            'defaults' => [
                'headers' => [
                    'X-ApiKey' => $config['apiKey'],
                ],
            ],
        ], [], $config);

        $description = self::getDescriptionFromConfig($config);

        $apiVersion = isset($config['apiVersion']) ? $config['apiVersion'] : 1;

        return new self($client, $description, ['defaults' => ['api_version' => $apiVersion]]);
    }
180118
protected function makeHTTPAdapter(array $config)
    {
        $client = $this->container->make('pubsub.http.client');
        $adapter = $this->make(
            $config['subscribe_connection_config']['driver'],
            $config['subscribe_connection_config']
        );
        return new HTTPPubSubAdapter($client, $config['uri'], $adapter);
    }
775852
public static function createServiceManager(array $config = [])
    {
        $serviceManager = new ServiceManager(new Config($config));

        $serviceManager->addInitializer(
            function ($instance, ServiceLocatorInterface $serviceLocator) {
                if ($instance instanceof ModelManagerAwareInterface) {
                    $instance->setModelManager($serviceLocator->get('modelmanager'));
                }
            }
        );

        $serviceManager->addInitializer(
            function ($instance, ServiceLocatorInterface $serviceLocator) {
                if ($instance instanceof ServiceLocatorAwareInterface) {
                    $instance->setServiceLocator($serviceLocator);
                }
            }
        );

        return $serviceManager;
    }
257880
public function fromConfig(array $config)
    {
        if ($this->env === 'dev' && php_sapi_name() !== 'cli') {
            //for performance reason only in dev mode: https://www.elastic.co/guide/en/elasticsearch/client/php-api/current/_configuration.html#enabling_logger
            $config['Tracer'] = $this->logger;
        }
        $config['connectionPool'] = SniffingConnectionPool::class;

        return ClientBuilder::fromConfig($config);
    }
497921
protected function createPdo(array $config)
    {
        $dsn        = $this->getHostDsn($config);
        $userName   = (isset($config['username']) ? $config['username'] : null);
        $password   = (isset($config['password']) ? $config['password'] : null);
        $options    = $this->getPdoOptions($config);

        return new PDO($dsn, $userName, $password, $options);
    }
930396
protected function createMemcachedDriver(array $config)
    {
        $prefix = $this->getPrefix($config);

        // Extract Plus features from config
        $persistentConnectionId = array_get($config, 'persistent_id');
        $customOptions = array_get($config, 'options', []);
        $saslCredentials = array_filter(array_get($config, 'sasl', []));

        $memcached = $this->app['memcached.connector']->connect(
            $config['servers'],
            $persistentConnectionId,
            $customOptions,
            $saslCredentials
        );

        return $this->repository(new MemcachedStore($memcached, $prefix));
    }
735881
public static function factory($config = array())
    {
        $defaults = array(
            'base_url' => 'http://localhost:8983',
            'base_path' => '/solr',
            'max_query_length' => self::MAX_QUERY_LENGTH,
        );

        $required = array(
            'base_url',
            'base_path',
            'max_query_length',
        );

        // Instantiate and return the Solr client.
        $config = Collection::fromConfig($config, $defaults, $required);
        $solr = new static($config->get('base_url'), $config);

        // Use URI template expansion in a way that doesn't break Solr.
        $solr->setUriTemplate(new SolrUriTemplate());

        // Use JSON whenever possible.
        // @see http://code.google.com/p/solr-php-client/issues/detail?id=6#c1
        $jsonParams = array(
            'wt'      => 'json',
            'json.nl' => 'map',
        );

        // Sometimes we have to use XML :-(.
        $xmlParams = array(
            'wt' => 'xml',
        );

        $solr
            ->setRequestHandler(new RequestHandler('luke',    'admin/luke',      'GET',  $jsonParams))
            ->setRequestHandler(new RequestHandler('mbeans',  'admin/mbeans',    'GET',  $xmlParams + array('stats' => 'true')))
            ->setRequestHandler(new RequestHandler('mlt',     'mlt',             'GET',  $jsonParams))
            ->setRequestHandler(new RequestHandler('ping',    'admin/ping',      'HEAD', $jsonParams))
            ->setRequestHandler(new RequestHandler('select',  'select',          'GET',  $jsonParams))
            ->setRequestHandler(new RequestHandler('spell',   'spell',           'GET',  $jsonParams))
            ->setRequestHandler(new RequestHandler('stats',   'admin/stats.jsp', 'GET',  $xmlParams))
            ->setRequestHandler(new RequestHandler('suggest', 'suggest',         'GET',  $jsonParams))
            ->setRequestHandler(new RequestHandler('system',  'admin/system',    'GET',  $jsonParams))
            ->setRequestHandler(new RequestHandler('update',  'update',          'POST', $jsonParams))
        ;

        return $solr;
    }
549620
public static function factory($config = array())
    {

        $defaults = array(
            'base_url'       => 'https://rpc.acquia.com',
            'server_address' => isset($_SERVER['SERVER_ADDR']) ? $_SERVER['SERVER_ADDR'] : '',
            'http_host'      => isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : '',
            'https'          => false,
            'network_id'     => '',
            'network_key'    => '',
        );

        // Instantiate the Acquia Search plugin.
        $config = Collection::fromConfig($config, $defaults);
        return new static(
            $config->get('base_url'),
            $config->get('network_id'),
            $config->get('network_key'),
            $config
        );
    }
143080
public function connect(array $config)
	{
		return new DatabaseQueue(
			$this->connections->connection(Arr::get($config, 'connection')),
			$config['table'],
			$config['queue'],
			Arr::get($config, 'expire', 60)
		);
	}
1321076
public function connect(array $config)
    {
        return new BeanstalkdQueue(
            $this->pheanstalk($config),
            $config['queue'],
            $config['retry_after'] ?? Pheanstalk::DEFAULT_TTR,
            $config['block_for'] ?? 0
        );
    }
824576
public function createFtpDriver(array $config)
    {
        $ftpConfig = Arr::only($config, [
            'host', 'username', 'password', 'port', 'root', 'passive', 'ssl', 'timeout',
        ]);

        return $this->adapt($this->createFlysystem(
            new FtpAdapter($ftpConfig), $config
        ));
    }