flavioheleno / favicon
A library to parse pages and web manifests to extract favicon images
Fund package maintenance!
Patreon
Requires
- php: >=8.1
- ext-dom: *
- ext-xml: *
- innmind/url-resolver: ^4.1
- masterminds/html5: ^2.7
- psr/http-client: ^1.0
- psr/http-client-implementation: ^1.0
- psr/http-factory: ^1.0
- psr/http-factory-implementation: ^1.0
- ramsey/collection: ^1.2
Requires (Dev)
- infection/infection: ^0.26
- kriswallsmith/buzz: ^1.2
- nyholm/psr7: ^1.5
- php-parallel-lint/php-parallel-lint: ^1.3
- phpstan/phpstan: ^1.4
- phpunit/phpunit: ^9.5
- psy/psysh: ^0.11
- roave/security-advisories: dev-latest
- squizlabs/php_codesniffer: ^3.6
- vimeo/psalm: ^4.8
This package is auto-updated.
Last update: 2024-11-11 22:30:42 UTC
README
A library to parse pages and web manifests to extract favicon images
Install
The best way to install the library is using the Composer Package Manager.
To install, run the following command:
php composer.phar require flavioheleno/favicon
This package is not tied to any specific library that sends HTTP Messages. Instead, it uses PSR-17 (HTTP Factories) and PSR-18 (HTTP Clients) to let developers choose whichever PSR-17 and PSR-18 implementations they want to use.
If you don't use any specific PSR-17 or PSR-18 libraries and want to get started right away you should run the following command:
php composer.phar require flavioheleno/favicon kriswallsmith/buzz nyholm/psr7
This will install the library itself along with a PSR-17 implementation (nyholm/psr7) and a PSR-18 implementation (kriswallsmith/buzz).
You can replace those libraries with any alternative library that provides HTTP Message Implementation (PSR-17) or HTTP Client Implementantion (PSR-18).
Usage
Extract all Icons
use Buzz\Client\Curl; use Favicon\Extractor; use Nyholm\Psr7\Factory\Psr17Factory; $extractor = new Extractor( new Curl(new Psr17Factory()), new Psr17Factory() ); $favicon = $extractor->from('https://twitter.com'); foreach ($favicon->getIconCollection() as $icon) { echo $icon->getRelationship(), ': ', $icon->getUrl(), PHP_EOL; }
manifest: https://abs.twimg.com/responsive-web/client-web-legacy/icon-default.ee534d85.png
manifest: https://abs.twimg.com/responsive-web/client-web-legacy/icon-default-large.8e027b65.png
manifest: https://abs.twimg.com/responsive-web/client-web-legacy/icon-default-maskable.2fd29c85.png
manifest: https://abs.twimg.com/responsive-web/client-web-legacy/icon-default-maskable-large.ee2b7aa5.png
shortcut icon: http://abs.twimg.com/favicons/twitter.2.ico
apple-touch-icon: https://abs.twimg.com/responsive-web/client-web-legacy/icon-ios.b1fc7275.png
License
This library is licensed under the MIT License.