Join 4,000+ others and never miss out on new tips, tutorials, and more.
4.x is outdated, please check the latest version 22.x
Latest version:
pecl install openswoole-22.1.2
<?php Swoole\Coroutine\FastCGI\Client::parseUrl(string $url): array
The URL you want to parse and get the host and port for.
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.
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.
<?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);