php8.5
Home/ Manual/ stomp / stomp/ Stomp::__construct

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

broker

The broker URI

username

The username.

password

The password.

Return Values Transaction

Changelog

VersionDescription
PECL stomp 1.0.1The 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);

?>

Source: reference/stomp/stomp/construct.xml · from the official PHP manual (php/doc-en)