inbox / tld-database
Database abstraction for Public Suffix List
Requires
- php: ^5.5.0 || ^7.0 || ^8.0
- ext-curl: *
- layershifter/tld-support: ^1.0.0
Requires (Dev)
- codeclimate/php-test-reporter: dev-master
- mikey179/vfsstream: ^1.6
- phpmd/phpmd: @stable
- phpunit/phpunit: ^4.8 || ^5.0
- squizlabs/php_codesniffer: ~2.0
- dev-master
- 10.71
- 1.0.70
- 1.0.69
- 1.0.68
- 1.0.67
- 1.0.66
- 1.0.65
- 1.0.64
- 1.0.63
- 1.0.62
- 1.0.61
- 1.0.60
- 1.0.59
- 1.0.58
- 1.0.57
- 1.0.56
- 1.0.55
- 1.0.54
- 1.0.53
- 1.0.52
- 1.0.51
- 1.0.50
- 1.0.49
- 1.0.48
- 1.0.47
- 1.0.46
- 1.0.45
- 1.0.44
- 1.0.43
- 1.0.42
- 1.0.41
- 1.0.40
- 1.0.39
- 1.0.38
- 1.0.37
- 1.0.36
- 1.0.35
- 1.0.34
- 1.0.33
- 1.0.32
- 1.0.31
- 1.0.30
- 1.0.29
- 1.0.28
- 1.0.27
- 1.0.26
- 1.0.25
- 1.0.24
- 1.0.23
- 1.0.22
- 1.0.21
- 1.0.20
- 1.0.19
- 1.0.18
- 1.0.17
- 1.0.16
- 1.0.15
- 1.0.14
- 1.0.13
- 1.0.12
- 1.0.11
- 1.0.10
- 1.0.9
- 1.0.8
- 1.0.7
- 1.0.6
- 1.0.5
- 1.0.4
- 1.0.3
- 1.0.2
- 1.0.1
- 1.0.0
This package is auto-updated.
Last update: 2024-11-18 19:24:29 UTC
README
Please use https://github.com/jeremykendall/php-domain-parser.
TLDDatabase
Abstraction layer for Public Suffix List in PHP. Used by TLDExtract.
Main idea of library provide easy and fast access to actual database of Public Suffix List. Library always supplied with actual database.
This package is compliant with PSR-1, PSR-2, PSR-4. If you notice compliance oversights, please send a patch via pull request.
Requirements
The following versions of PHP are supported:
- PHP 5.5
- PHP 5.6
- PHP 7.0
- PHP 7.1
- HHVM
Basic usage
First of all you need load Store class.
$store = new \LayerShifter\TLDDatabase\Store();
For check existence of entry in database you need use isExists
method:
$store->isExists(string $suffix) : bool; $store->isExists('com'); // true $store->isExists('comcom'); // false
Note: suffix must be without leading dot.
For get type of suffix you need use getType
method:
For check existence of entry in database you need use isExists
method:
$store->isExists(string $suffix): int; $store->getType('com'); // \LayerShifter\TLDDatabase\Store::TYPE_ICANN = 1 $store->getType('s3.amazonaws.com'); // \LayerShifter\TLDDatabase\Store::TYPE_PRIVATE = 2
If entry doesn't exists method will throw exception, else it will return one of integer constants:
\LayerShifter\TLDDatabase\Store::TYPE_ICANN
;\LayerShifter\TLDDatabase\Store::TYPE_PRIVATE
;
For direct check of type you can use isICANN
or isPrivate
method.
$store->isICANN(string $suffix) : bool; $store->isICANN'com'); // true $store->isICANN('s3.amazonaws.com'); // false $store->isPrivate(string $suffix) : bool; $store->isPrivate('com'); // false $store->isPrivate('s3.amazonaws.com'); // true
Advanced usage
There are some cool features for developers.
Custom database
If you need operate with custom (non-packaged) database you simply need to add argument to Store
constructor.
$store = new \LayerShifter\TLDDatabase\Store(string $filename); $store = new \LayerShifter\TLDDatabase\Store(__DIR__ . '/cache/datatabase.php');
Update
If you use custom database you need update it 😉 So, you can use Update
class.
$update = new \LayerShifter\TLDDatabase\Update(string $filename); $update = new \LayerShifter\TLDDatabase\Update(__DIR__ . '/cache/datatabase.php'); $update->run();
HTTP-adapter
Basically library uses cURL adapter for updates, but you can use custom adapter.
class customHttp implements \LayerShifter\TLDDatabase\Http\AdapterInterface { public function get() {} } $update = new \LayerShifter\TLDDatabase\Update(__DIR__ . '/cache/datatabase.php', 'customHttp'); $update->run();
Install
Via Composer
$ composer require layershifter/tld-database
Testing
$ composer test
Versioning
Library uses SemVer versioning. Where:
- major makes incompatible API changes;
- minor adds functionality, fully backwards-compatible;
- patch is update of database from Public Suffix List.
Database has every week update cycle.
Contributing
Please see CONTRIBUTING and CONDUCT for details.
License
This library is released under the Apache 2.0 license. Please see License File for more information.