Stomp::__construct
PHP function
Edit on GitHub ✎
(PECL stomp >= 0.1.0)
Opens a connection
Description
Oop (constructor):
Stomp::__construct(string $broker = ini_get("stomp.default_broker_uri"), [string $username], [string $password], [array $headers])
Procedural:
stomp_connect(string $broker = ini_get("stomp.default_broker_uri"), [string $username], [string $password], [array $headers]): resource
Opens a connection to a stomp compliant Message Broker.
Parameters
brokerThe broker URI
usernameThe username.
passwordThe password.
Return Values Transaction
Changelog
| Version | Description |
|---|---|
| PECL stomp 1.0.1 | The headers parameter was added |
Examples
Oop
php
<?php
/* connection */
try {
$stomp = new Stomp('tcp://localhost:61613');
} catch(StompException $e) {
die('Connection failed: ' . $e->getMessage());
}
/* close connection */
unset($stomp);
?>Procedural
php
<?php
/* connection */
$link = stomp_connect('ssl://localhost:61612');
/* check connection */
if (!$link) {
die('Connection failed: ' . stomp_connect_error());
}
/* close connection */
stomp_close($link);
?>