Swoole\Coroutine\FastCGI\Client->parseUrl(...)

Declaration

<?php
Swoole\Coroutine\FastCGI\Client::parseUrl(string $url): array

Parameters

url

The URL you want to parse and get the host and port for.

Return

Returns the host and port from the URL, if a UnixSocket is used, only the host is returned, so port will be 0 if a socket is used.


Description

This is a static method used to parse the given URL through the PHP parse_url method and get the host and port components.

Note: This method is more for internal usage with the client but it is made public for you as some situations may benefit from it.


Example

<?php

// IP Address
[$host, $port] = Swoole\Coroutine\FastCGI\Client::parseUrl('127.0.0.1:9000');

var_dump($host, $port);

// UnixSocket
[$host, $port] = Swoole\Coroutine\FastCGI\Client::parseUrl('unix://tmp/php-fpm.sock');

var_dump($host, $port);