/** * Constructor * * @param string $uri - Uri. Eg: beanstalk://localhost */ public function __construct($uri) { $parts = parse_url($uri); $host = @$parts['host'] ?: 'localhost'; $port = @$parts['port'] ?: 11300; $this->pheanstalk = new Pheanstalk($host, $port); if ($queueName = ltrim(@$parts['path'], '/')) { if (in_array(substr($queueName, -1), array('-', '_'))) { parent::__construct($queueName); } else { $this->setQueueName($queueName); } } }
/** * Constructor * * @param string $uri - Uri. Eg: http://sqs.ap-southeast-1.amazonaws.com/71203182391283/sample-queue */ public function __construct($uri) { $parts = parse_url($uri); $this->scheme = @$parts['scheme'] ?: 'https'; $hParts = explode('.', $parts['host'], 3); $this->region = @$hParts[1] ?: 'ap-southeast-1'; $accessKey = @$parts['user'] ?: ''; $accessSecret = @$parts['pass'] ?: ''; $this->sqs = SqsClient::factory(array('key' => $accessKey, 'secret' => $accessSecret, 'region' => $this->region)); if ($path = ltrim(@$parts['path'], '/')) { $pParts = explode('/', $path, 2); $this->accountId = $pParts[0]; if (count($pParts) > 1 && ($queueName = $pParts[1])) { if (in_array(substr($queueName, -1), array('-', '_'))) { parent::__construct($queueName); } else { $this->setQueueName($queueName); } } } }