本文整理汇总了PHP中static::client方法的典型用法代码示例。如果您正苦于以下问题:PHP static::client方法的具体用法?PHP static::client怎么用?PHP static::client使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类static
的用法示例。
在下文中一共展示了static::client方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createGuzzleClient
/**
* @param $tempDir
* @param array $guzzleConfig
* @return \GuzzleHttp\Client
* @throws \Matyx\Guzzlette\GuzzletteException
*/
public static function createGuzzleClient($tempDir, $guzzleConfig = [])
{
if (isset(static::$client)) {
return static::$client;
}
if (Tracy\Debugger::isEnabled()) {
$handler = NULL;
if (isset($guzzleConfig['handler'])) {
$handler = $guzzleConfig['handler'];
if (!$handler instanceof GuzzleHttp\HandlerStack) {
throw new GuzzletteException("Handler must be instance of " . GuzzleHttp\HandlerStack::class);
}
} else {
$handler = GuzzleHttp\HandlerStack::create();
}
$requestStack = new RequestStack();
Tracy\Debugger::getBar()->addPanel(new TracyPanel($tempDir, $requestStack));
$handler->push(function (callable $handler) use($requestStack) {
return function ($request, array $options) use($handler, $requestStack) {
Tracy\Debugger::timer();
$guzzletteRequest = new Request();
$guzzletteRequest->request = $request;
return $handler($request, $options)->then(function ($response) use($requestStack, $guzzletteRequest) {
$guzzletteRequest->time = Tracy\Debugger::timer();
$guzzletteRequest->response = $response;
$requestStack->addRequest($guzzletteRequest);
return $response;
});
};
});
$guzzleConfig['handler'] = $handler;
}
static::$client = new GuzzleHttp\Client($guzzleConfig);
return static::$client;
}
示例2: getClient
/**
* Get the Algolia client associated with this instance.
*
* @return \AlgoliaSearch\Client
*/
protected function getClient()
{
if (!static::$client) {
static::$client = new \AlgoliaSearch\Client(Config::get('search.connections.algolia.config.application_id'), Config::get('search.connections.algolia.config.admin_api_key'));
}
return static::$client;
}
示例3: setUp
/**
* {@inheritdoc}
*/
protected function setUp()
{
$fs = new Filesystem();
$fs->remove(__DIR__ . static::$TEMP_PATH);
static::$client = static::createClient(['config' => static::$CONFIG_FILE]);
static::$router = static::$kernel->getContainer()->get('router');
}
示例4: getStaticClient
/**
* Get the static HTTP client
*
* @param array|Traversable $options
* @return Client
*/
protected static function getStaticClient($options = null)
{
if (!isset(static::$client) || $options !== null) {
static::$client = new Client(null, $options);
}
return static::$client;
}
示例5: setUpBeforeClass
public static function setUpBeforeClass()
{
static::$client = static::createClient();
static::$router = self::$client->getContainer()->get('router');
static::$em = self::$client->getContainer()->get('doctrine.orm.entity_manager');
static::$container = self::getContainer();
}
示例6: getClient
/**
* Singleton object getter.
*
* @param string $wsdl
* @return SoapClient instance.
*/
public static function getClient($wsdl)
{
if (!static::$client) {
static::$client = new static($wsdl);
}
return static::$client;
}
示例7: getClient
/**
* Get the Elasticsearch client associated with this instance.
*
* @return \Elasticsearch\Client
*/
protected function getClient()
{
if (!static::$client) {
static::$client = new \Elasticsearch\Client(Config::get('search.connections.elasticsearch.config', array()));
}
return static::$client;
}
示例8: client
/**
* Get api client for consuming api
*
* @return Client
* @throws Exception
*/
public function client()
{
if (!static::$client) {
static::$client = new Client(array('base_uri' => $this->apiUrl, 'cookies' => $this->jar));
}
return static::$client;
}
示例9: _init
/**
* Initialize
*/
public static function _init()
{
$config = \Config::load('sentry', true);
static::$config = $config[\Fuel::$env];
// create instance for PHP
static::$client = new \Raven_Client(static::$config['php']['dsn']);
}
示例10: getClient
/**
* Get the Guzzle client for requests
*
* @return Client
*/
protected static function getClient()
{
if (!static::$client) {
static::$client = new Client('https://graph.facebook.com');
}
return static::$client;
}
示例11: getClient
protected static function getClient()
{
if (null === static::$client) {
static::$client = new \SoapClient(static::$baseUrl . "?wsdl", array('location' => static::$baseUrl, 'cache_wsdl' => WSDL_CACHE_NONE));
}
return static::$client;
}
示例12: getBitBucketClient
/**
* @param array $options
*
* @return BitBucketClient
*/
protected static function getBitBucketClient(array $options = [])
{
if (null === static::$client || static::$client->getOptions() !== $options) {
static::$client = new BitBucketClient($options);
}
return static::$client;
}
示例13: getStaticClient
/**
* Get the static HTTP client
*
* @return Client
*/
protected static function getStaticClient()
{
if (!isset(static::$client)) {
static::$client = new Client();
}
return static::$client;
}
示例14: auth
public static function auth()
{
$news = new Zend_Gdata_Photos();
$svc = Zend_Gdata_Photos::AUTH_SERVICE_NAME;
static::$client = Zend_Gdata_ClientLogin::getHttpClient(static::$gUser, static::$gPass, $svc);
static::$service = new Zend_Gdata_Photos(static::$client, "ANO");
}
示例15: getGitlabClient
/**
* @param string $url
*
* @return Client
*/
protected static function getGitlabClient($url)
{
if (null === static::$client || static::$client->getBaseUrl() !== $url) {
static::$client = new Client(trim($url, '/') . '/');
}
return static::$client;
}