Skip to content

Instantly share code, notes, and snippets.

@melkamar
Created November 26, 2018 15:22
Show Gist options
  • Save melkamar/f98e8996dc55a2e457a6efeed2154ee1 to your computer and use it in GitHub Desktop.
Save melkamar/f98e8996dc55a2e457a6efeed2154ee1 to your computer and use it in GitHub Desktop.
Janephp issue
<?php
// This is what is generated by janephp
public static function create($httpClient = null)
{
if (null === $httpClient) {
$httpClient = \Http\Discovery\HttpClientDiscovery::find();
$plugins = array();
$uri = \Http\Discovery\UriFactoryDiscovery::find()->createUri('relative/path/v1');
$plugins[] = new \Http\Client\Common\Plugin\AddPathPlugin($uri);
$httpClient = new \Http\Client\Common\PluginClient($httpClient, $plugins);
}
$messageFactory = \Http\Discovery\MessageFactoryDiscovery::find();
$streamFactory = \Http\Discovery\StreamFactoryDiscovery::find();
$serializer = new \Symfony\Component\Serializer\Serializer(...);
return new static($httpClient, $messageFactory, $serializer, $streamFactory);
}
<?php
// This is what I need to achieve
public static function create($httpClient = null)
{
if (null === $httpClient) {
$httpClient = \Http\Discovery\HttpClientDiscovery::find();
$plugins = array();
$uri = \Http\Discovery\UriFactoryDiscovery::find()->createUri('relative/path/v1');
$plugins[] = new \Http\Client\Common\Plugin\AddPathPlugin($uri);
// This is what I need to do:
$host = UriFactoryDiscovery::find()->createUri('http://api.site.com:8080');
$plugins[] = new \Http\Client\Common\Plugin\AddHostPlugin($host);
$httpClient = new \Http\Client\Common\PluginClient($httpClient, $plugins);
}
$messageFactory = \Http\Discovery\MessageFactoryDiscovery::find();
$streamFactory = \Http\Discovery\StreamFactoryDiscovery::find();
$serializer = new \Symfony\Component\Serializer\Serializer(...);
return new static($httpClient, $messageFactory, $serializer, $streamFactory);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment