mirror of https://github.com/YGGverse/net-php.git
composernetworkipv6network-apiipv4dnsdns-php-libraryphp-digdns-phpdns-resolver-apiphp-resolverdignet-php
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
yggverse
16f90cb23b
|
9 months ago | |
---|---|---|
src | 9 months ago | |
.gitignore | 1 year ago | |
LICENSE | 1 year ago | |
README.md | 9 months ago | |
composer.json | 1 year ago |
README.md
net-php
Network Library for PHP with native Yggdrasil support
Install
composer require yggverse/net
Usage
Socket
Check socket is open
var_dump(
\Yggverse\Net\Socket::isOpen('yo.index', 80)
);
Check host valid
var_dump(
\Yggverse\Net\Socket::isHost('yo.index')
);
Check port valid
var_dump(
\Yggverse\Net\Socket::isPort(80)
);
Dig
Resolve records
var_dump(
\Yggverse\Net\Dig::records('yo.index', ['A', 'AAAA'])
);
Check hostname valid
var_dump(
\Yggverse\Net\Dig::isHostName('yo.index')
);
Check record valid
var_dump(
\Yggverse\Net\Dig::isRecord('A')
);
Check record value valid
var_dump(
\Yggverse\Net\Dig::isRecordValue('A', '127.0.0.1')
);
Address
Includes methods to work with network addresses.
Base address methods
Different operations with address parts:
scheme
user
password
host
protocol
path
query
fragment
Address conversion from relative to absolute format
Document root
$base = new \Yggverse\Net\Address(
'http://yo.ygg/a1/b1/c1'
);
$address = new \Yggverse\Net\Address(
'/a2'
);
var_dump(
$address->getAbsolute(
$base
) // return http://yo.ygg/a2
);
Current folder
$base = new \Yggverse\Net\Address(
'http://yo.ygg/a1/b1/c1'
);
$address = new \Yggverse\Net\Address(
'c2'
);
var_dump(
$address->getAbsolute(
$base
) // return http://yo.ygg/a1/b1/c2
);
Ending slash
$base = new \Yggverse\Net\Address(
'http://yo.ygg/a1/b1/c1/'
);
$address = new \Yggverse\Net\Address(
'../../b2/c2'
);
var_dump(
$address->getAbsolute(
$base
) // return http://yo.ygg/a1/b2/c2
);
All options
$base = new \Yggverse\Net\Address(
'http://user:password@yo.ygg/a1/b1/c1?attribute=value#anchor'
);
$address = new \Yggverse\Net\Address(
'../../a2/b2?attribute2=value2#anchor2'
);
var_dump(
$address->getAbsolute(
$base
) // return http://user:password@yo.ygg/a2/b2?attribute2=value2#anchor2
);