Skip to content

Commit fc21003

Browse files
authored
Merge pull request #255 from jeremykendall/develop
5.6.0 release
2 parents 93efea6 + b234707 commit fc21003

13 files changed

+594
-84
lines changed

.php_cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ file that was distributed with this source code.
1212
EOF;
1313

1414
$finder = PhpCsFixer\Finder::create()
15+
->in(__DIR__.'/bin')
1516
->in(__DIR__.'/src')
1617
->in(__DIR__.'/tests')
1718
;
@@ -55,4 +56,4 @@ return PhpCsFixer\Config::create()
5556
'whitespace_after_comma_in_array' => true,
5657
])
5758
->setFinder($finder)
58-
;
59+
;

.travis.yml

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ matrix:
3232
- VALIDATE_CODING_STYLE=false
3333
- RUN_PHPSTAN=false
3434
- IGNORE_PLATFORMS=true
35-
- php: 7.4snapshot
35+
- php: 7.4
3636
env:
3737
- COLLECT_COVERAGE=false
3838
- VALIDATE_CODING_STYLE=false
@@ -42,17 +42,12 @@ matrix:
4242
env:
4343
- COLLECT_COVERAGE=false
4444
- IGNORE_PLATFORMS=true
45-
- RUN_PHPSTAN=true
45+
- RUN_PHPSTAN=false
4646
- VALIDATE_CODING_STYLE=false
4747
allow_failures:
48-
- php: 7.4snapshot
4948
- php: nightly
5049
fast_finish: true
5150

52-
cache:
53-
directories:
54-
- $HOME/.composer/cache
55-
5651
before_install:
5752
- travis_retry composer self-update
5853

@@ -66,4 +61,4 @@ script:
6661
- composer phpunit
6762

6863
after_script:
69-
- if [ "$COLLECT_COVERAGE" == "true" ]; then wget https://scrutinizer-ci.com/ocular.phar && php ocular.phar code-coverage:upload --format=php-clover build/clover.xml; fi
64+
- if [ "$COLLECT_COVERAGE" == "true" ]; then wget https://scrutinizer-ci.com/ocular.phar && php ocular.phar code-coverage:upload --format=php-clover build/clover.xml; fi

CHANGELOG.md

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,26 @@
22

33
All Notable changes to `PHP Domain Parser` **5.x** series will be documented in this file
44

5-
# 5.5.0 - 2019-04-14
5+
## 5.6.0 - 2019-12-29
6+
7+
### Added
8+
9+
- A simple `Psr3` compatible logger class which output the logs to you cli console.
10+
11+
### Fixed
12+
13+
- `composer.json` updated to be composer 2.0 ready
14+
- package bundle installer is rewritten to improve its usage see [#249](https://github.com/jeremykendall/php-domain-parser/issues/249) and [#250](https://github.com/jeremykendall/php-domain-parser/issues/250)
15+
16+
### Deprecated
17+
18+
- None
19+
20+
### Removed
21+
22+
- None
23+
24+
## 5.5.0 - 2019-04-14
625

726
### Added
827

@@ -25,7 +44,7 @@ All Notable changes to `PHP Domain Parser` **5.x** series will be documented in
2544

2645
- None
2746

28-
# 5.4.0 - 2018-11-22
47+
## 5.4.0 - 2018-11-22
2948

3049
### Added
3150

@@ -161,4 +180,4 @@ All Notable changes to `PHP Domain Parser` **5.x** series will be documented in
161180
- `Pdp\PublicSuffixList` class replaced by the `Pdp\Rules` class
162181
- `Pdp\PublicSuffixManager` class replaced by the `Pdp\Manager` class
163182
- `Pdp\HttpAdapter\HttpAdapterInterface` interface replaced by the `Pdp\HttpClient` interface
164-
- `Pdp\HttpAdapter\CurlHttpAdapter` class replaced by the `Pdp\CurlHttpClient` class
183+
- `Pdp\HttpAdapter\CurlHttpAdapter` class replaced by the `Pdp\CurlHttpClient` class

LICENSE

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
Copyright (C) 2013-2014 Jeremy Kendall, http://about.me/jeremykendall
1+
The MIT License (MIT)
2+
3+
Copyright (C) 2013-2019 Jeremy Kendall, http://about.me/jeremykendall
24

35
Permission is hereby granted, free of charge, to any person obtaining a copy of
46
this software and associated documentation files (the "Software"), to deal in

README.md

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ Dependencies
3434
-------
3535

3636
- [PSR-16](http://www.php-fig.org/psr/psr-16/)
37+
- [PSR-3](http://www.php-fig.org/psr/psr-3/) *since version 5.6*
3738

3839
Installation
3940
--------
@@ -555,8 +556,9 @@ This script requires:
555556
- The PHP `curl` extension
556557
- The `Pdp\Installer` class which organizes how to update the cache.
557558
- The `Pdp\Cache` and `Pdp\CurlHttpClient` classes to retrieve and cache the PSL
559+
- A `Psr3` implementation.
558560

559-
You can also add a composer script in your `composer.json` file to update the PSL cache everytime after the `install` or the `update` command are executed.
561+
You can add a composer script in your `composer.json` file to update the PSL cache every time after the `install` or the `update` command are executed.
560562

561563
~~~bash
562564
{
@@ -567,12 +569,36 @@ You can also add a composer script in your `composer.json` file to update the PS
567569
}
568570
~~~
569571

570-
If you prefer using your own implementations you should:
572+
#### Advanced usage of the update-psl script
571573

572-
1. Copy the `Pdp\Installer` class
573-
2. Adapt its code to reflect your requirements.
574+
**since version 5.6.0**
574575

575-
In any case, your are required to update regularly your PSL information with your chosen script to keep your data up to date.
576+
The following command is accessible to the end user:
577+
578+
```bash
579+
$ php bin/update-psl --rzd --rzd-url=http://localhost/rzd-mirror/list.txt --ttl="8 HOURS" --cache-dir="/tmp"
580+
````
581+
582+
This lines means:
583+
584+
- the only cache that will be updated will be the one for the Root Zone Domains;
585+
- it will be updated using the submitted URL;
586+
- the data will be cached for 8 hours;
587+
- the cache directory will be the `/tmp` directory.;
588+
589+
##### Options and arguments
590+
591+
- `--cache-dir` : specify the root directory used to save the cached data;
592+
- `h`, `--h`, `--help` : display the helper message;
593+
- `--psl`: specify that the PSL cache must be updated;
594+
- `--psl-url`: specify that PSL source URL;
595+
- `--rzd`: specify that the RZD cache must be updated;
596+
- `--rzd-url`: specify that RZD source URL;
597+
- `--ttl`: specify the cache TTL;
598+
599+
#### Alternatives to the update-psl script
600+
601+
**Using the `update-psl` script is not a requirement but your MUST update regularly your PSL information to keep your cache data up to date.**
576602

577603
For example, below I'm using the `Manager` with
578604
@@ -717,4 +743,4 @@ the Apache Software Foundation License 2.0 in this project.
717743
[link-release]: https://github.com/jeremykendall/php-domain-parser/releases
718744
[link-license]: https://github.com/jeremykendall/php-domain-parser/blob/master/LICENSE
719745
720-
[link-parse-library]: https://packagist.org/explore/?query=rfc3986
746+
[link-parse-library]: https://packagist.org/explore/?query=rfc3986

bin/update-psl

Lines changed: 131 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,135 @@
11
#!/usr/bin/env php
22
<?php
33

4-
require dirname(__DIR__).'/src/Installer.php';
4+
/**
5+
* PHP Domain Parser: Public Suffix List based URL parsing.
6+
*
7+
* @see http://github.com/jeremykendall/php-domain-parser for the canonical source repository
8+
*
9+
* @copyright Copyright (c) 2017 Jeremy Kendall (http://jeremykendall.net)
10+
*
11+
* For the full copyright and license information, please view the LICENSE
12+
* file that was distributed with this source code.
13+
*/
514

6-
Pdp\Installer::updateLocalCache();
15+
declare(strict_types=1);
16+
17+
use Pdp\Logger;
18+
use Pdp\Installer;
19+
use Pdp\Manager;
20+
21+
require dirname(__DIR__).'/vendor/autoload.php';
22+
23+
function writeln(array $messages, $output): int
24+
{
25+
$message = implode(PHP_EOL, $messages). PHP_EOL;
26+
27+
return fwrite($output, $message);
28+
}
29+
30+
function success(string $message, $output = STDOUT): int
31+
{
32+
$messages = (array) $message;
33+
34+
return writeln($messages, $output);
35+
}
36+
37+
function fail(string $message, $output = STDERR): int
38+
{
39+
$messages = (array) $message;
40+
41+
return writeln($messages, $output);
42+
}
43+
44+
/**
45+
* CLI colors
46+
*/
47+
$cyan = chr(27)."[36m";
48+
$green = chr(27)."[32m";
49+
$reset = chr(27)."[0m";
50+
$redbg = chr(27)."[41m";
51+
$yellow = chr(27)."[33m";
52+
53+
$arguments = array_replace([
54+
Installer::CACHE_DIR_KEY => '',
55+
Installer::REFRESH_PSL_KEY => false,
56+
Installer::REFRESH_RZD_KEY => false,
57+
Installer::TTL_KEY => '1 DAY',
58+
], getopt('h::', [
59+
'h',
60+
'help',
61+
Installer::CACHE_DIR_KEY.':',
62+
Installer::REFRESH_PSL_KEY,
63+
Installer::REFRESH_PSL_URL_KEY.':',
64+
Installer::REFRESH_RZD_KEY,
65+
Installer::REFRESH_RZD_URL_KEY.':',
66+
Installer::TTL_KEY.':',
67+
]));
68+
69+
if (isset($arguments['help']) || isset($arguments['h'])) {
70+
$default_cache_dir = dirname(__DIR__).'/data';
71+
$script = basename(__FILE__);
72+
$helpText = <<<HELP
73+
{$yellow}Usage:$reset
74+
$script [options]
75+
76+
{$yellow}Options:$reset
77+
$green --%s$reset refreshes the Public Suffix List cache
78+
$green --%s=URL$reset set the URL to use to refresh the PSL cache ({$yellow}default:$reset %s)
79+
$green --%s$reset refreshes the IANA Root Zone Database cache
80+
$green --%s=URL$reset set the URL to use to refresh the RZD cache ({$yellow}default:$reset %s)
81+
$green --%s=TTL$reset set the TTL for the cache ({$yellow}default:$reset '1 DAY')
82+
$green --%s=CACHE-DIR$reset set the cache root directory ({$yellow}default:$reset $default_cache_dir')
83+
$green-h, --help$reset show the following help message
84+
85+
{$yellow}Help:$reset
86+
The {$green}update-psl$reset command updates your PDP local cache.
87+
88+
{$yellow}Examples:$reset
89+
90+
Refresh all caches using the default settings
91+
$green$script$reset
92+
93+
Refresh only the PSL cache for a TTL of 3 DAY
94+
$green$script --psl --ttl="3 DAYS"$reset
95+
96+
Refresh all caches using another cache directory
97+
$green$script --cache-dir=/temp$reset
98+
99+
Read more at https://github.com/jeremykendall/php-domain-parser/
100+
101+
HELP;
102+
103+
$helpText = sprintf($helpText,
104+
Installer::REFRESH_PSL_KEY,
105+
Installer::REFRESH_PSL_URL_KEY,
106+
Manager::PSL_URL,
107+
Installer::REFRESH_RZD_KEY,
108+
Installer::REFRESH_RZD_URL_KEY,
109+
Manager::RZD_URL,
110+
Installer::TTL_KEY,
111+
Installer::CACHE_DIR_KEY
112+
);
113+
114+
success($helpText);
115+
116+
die(0);
117+
}
118+
119+
if (!extension_loaded('curl')) {
120+
fail("$redbg The required PHP cURL extension is missing. $reset");
121+
122+
die(1);
123+
}
124+
125+
$installer = Installer::createFromCacheDir(new Logger( STDOUT, STDERR), $arguments[Installer::CACHE_DIR_KEY]);
126+
success("$yellow Updating your Pdp local cache.$reset");
127+
if ($installer->refresh($arguments)) {
128+
success("$green Pdp local cache successfully updated. $reset");
129+
130+
die(0);
131+
}
132+
133+
fail("$redbg The command failed to update Pdp local cache successfully. $reset");
134+
135+
die(1);

composer.json

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,13 @@
3636
"require": {
3737
"php": ">=7.0",
3838
"ext-intl": "*",
39+
"psr/log": "^1.1",
3940
"psr/simple-cache": "^1.0.1"
4041
},
4142
"require-dev": {
4243
"composer/composer": "^1.6",
4344
"friendsofphp/php-cs-fixer": "^2.7",
44-
"mikey179/vfsStream": "^1.6",
45+
"mikey179/vfsstream": "^1.6",
4546
"phpstan/phpstan": "^0.9.2",
4647
"phpstan/phpstan-phpunit": "^0.9.4",
4748
"phpstan/phpstan-strict-rules": "^0.9.0",
@@ -63,9 +64,9 @@
6364
}
6465
},
6566
"scripts": {
66-
"phpcs": "php-cs-fixer fix -vv --diff --dry-run --allow-risky=yes",
67-
"phpstan-src": "phpstan analyse -l max -c phpstan.src.neon src",
68-
"phpstan-tests": "phpstan analyse -l max -c phpstan.tests.neon tests",
67+
"phpcs": "php-cs-fixer fix -vvv --diff --dry-run --allow-risky=yes --ansi",
68+
"phpstan-src": "phpstan analyse -l max -c phpstan.src.neon src --ansi",
69+
"phpstan-tests": "phpstan analyse -l max -c phpstan.tests.neon tests --ansi",
6970
"phpstan": [
7071
"@phpstan-src",
7172
"@phpstan-tests"
@@ -79,6 +80,14 @@
7980
"@phpunit"
8081
]
8182
},
83+
"scripts-descriptions": {
84+
"phpcs": "Runs coding style test suite",
85+
"phpstan": "Runs complete codebase static analysis",
86+
"phpstan-src": "Runs PHP stan on the source code",
87+
"phpstan-test": "Runs PHP stan on the test suite",
88+
"phpunit": "Runs unit and functional testing",
89+
"test": "Runs the complete test suite"
90+
},
8291
"extra": {
8392
"branch-alias": {
8493
"dev-master": "5.x-dev"

data/pdp-PSL_FULL_5a3cc7f81795bb2e48e848af42d287b4.cache

100755100644
Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)