downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | conferences | my php.net

search for in the

AMQPConnection::disconnect> <AMQPConnection::connect
[edit] Last updated: Fri, 17 May 2013

view this page in

AMQPConnection::__construct

(PECL amqp >= Unknown)

AMQPConnection::__constructCreate an instance of AMQPConnection

Beschreibung

public AMQPConnection::__construct ([ array $credentials = array() ] )

Creates an AMQPConnection instance representing a connection to an AMQP broker.

Parameter-Liste

credentials

The credentials is an optional array of credential information for connecting to the AMQP broker.

Supported indexes
key Description Default value
host The host to connect too

Hinweis: Max 1024 characters

amqp.host
port Port on the host amqp.port
vhost The virtual host on the host

Hinweis: Max 128 characters

amqp.vhost
login The login name to use.

Hinweis: Max 128 characters

amqp.login
password Password

Hinweis: Max 128 characters

amqp.password

All other keys will be ignored.

Rückgabewerte

An AMQPConnection object.

Fehler/Exceptions

Throws AMQPException exception on parameter parsing failures, and option errors.

Beispiele

Beispiel #1 AMQPConnection::__construct() example

<?php

/* Create a connection using the INI values */
$connection1 = new AMQPConnection();

/* Specifying all keys */
$connection2 = new AMQPConnection(array(
    
'host' => 'example.host',
    
'vhost' => '/',
    
'port' => 5763,
    
'login' => 'user',
    
'password' => 'password'
));

?>

Anmerkungen

Hinweis:

A connection will not be established until AMQPConnection::connect() is called.



add a note add a note User Contributed Notes AMQPConnection::__construct - [2 notes]
up
0
pinepain at gmail dot com
5 months ago
It is not documented here, but additional key supported for AMQP

Version => 1.0.9
Revision => $Revision: 327551 $
AMQP protocol version => 0-9-1
librabbitmq version => 0.2.0

timeout     Timeout to wait for a new messages    float   amqp.timeout
up
0
bolo at nospam dot autistici dot org
1 year ago
A simply function that help manage connections to AMQP server.
It works fine in debian wheezy php 5.3.8.
Change Login & Password value at your plasure.
(Host will be the default value = 127.0.0.1).

<?php
function amqp_connection() {

   
$connection = new AMQPConnection();
   
$connection->setLogin('guest');
   
$connection->setPassword('guest');
   
$connection->connect();

    if (!
$connection->isConnected()) {
         echo
"Cannot connect to the broker";
    }
    return
$connection;
}

//Next manage the connection with $connection var

// function ...

// $connection=amqp_connection();

// ...
?>

 
show source | credits | stats | sitemap | contact | advertising | mirror sites