w2w / apie-domain-plugin
Adds Domain value objects to Apie
Installs: 2 110
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 1
Open Issues: 0
Requires
- php: ^7.2
- jeremykendall/php-domain-parser: ^5.6
- w2w/apie: ^4.0
Requires (Dev)
- orchestra/testbench: 3.6.*
- phpunit/phpunit: ^7.0|^8.0
This package is auto-updated.
Last update: 2022-06-12 09:59:54 UTC
README
Apie Plugin to make Domain objects work.
This is done with the library jeremykendall/php-domain-parser.
Installation
Just use composer to install this package.
composer require w2w/apie-domain-plugin
Using it in Apie directly
In case you use no framework, you can easily make it work with when you create the Apie object.
<?php use W2w\Lib\Apie\Apie; use W2w\Lib\ApieDomainPlugin\DomainPlugin; $apie = new Apie([new DomainPlugin()], true, null);
If you want to mock the call to get the public suffixes or have your own initialization of the php domain parser you can provide it in the constructor:
<?php use Pdp\Cache; use Pdp\Manager; use Pdp\Rules; use W2w\Lib\Apie\Apie; use W2w\Lib\ApieDomainPlugin\DomainPlugin; use W2w\Lib\ApieDomainPlugin\HttpClient\MockHttpClient; $manager = new Manager( new Cache(sys_get_temp_dir()), new MockHttpClient() ); $rules = $manager->getRules(Rules::ICANN_DOMAINS); $apie = new Apie([new DomainPlugin($rules)], true, null);
integrating with Laravel-apie
If you use apie with Laravel with w2w/laravel-apie you can just install this package with composer. If auto-wiring is off you require to manually add W2w\Lib\ApieDomainPlugin\DomainPluginServiceProvider::class to the list of service providers.
You still need to manually add the plugin in the config of laravel-apie:
<?php // config/apie.php use W2w\Lib\ApieDomainPlugin\DomainPlugin; return [ 'plugins' => [DomainPlugin::class], ];
mocking
With environment variable APIE_DOMAIN_PLUGIN_MOCK you can enable mocking which is also recommended for testing. It will load a static file instead for the public suffixes.