myerscode / utilities-web
A fluent interface for interacting with web page content and urls.
2026.0.0
2026-03-31 07:39 UTC
Requires
- php: ^8.5
- ext-curl: *
- ext-dom: *
- ext-filter: *
- league/uri: ^7.5
- league/uri-components: ^7.5
- php-curl-class/php-curl-class: ^12.0
- symfony/dom-crawler: ^8.0
- symfony/http-client: ^8.0
Requires (Dev)
- ext-sockets: *
- donatj/mock-webserver: ^2.6
- laravel/pint: ^1.29
- mockery/mockery: ^1.6
- phpstan/phpstan: ^2.1
- phpunit/phpunit: ^13.0
This package is auto-updated.
Last update: 2026-04-03 23:18:40 UTC
README
A fluent interface for interacting with web sites, page content and URLs.
Requirements
- PHP >= 8.5
- ext-curl
- ext-dom
- ext-filter
Install
composer require myerscode/utilities-web
Usage
use Myerscode\Utilities\Web\Utility; $web = new Utility('https://example.com'); // or use the static factory $web = Utility::make('https://example.com'); // Get content from a URL $content = $web->content()->content(); // Get a DOM crawler for the page $dom = $web->content()->dom(); // Decode JSON responses $data = $web->content()->json(); // Ping a host $result = $web->ping()->ping(); $alive = $web->ping()->isAlive(); // Quick liveness check $web->isAlive(); // Work with URLs $uri = $web->url(); // Check response status $response = $web->response()->check(\Myerscode\Utilities\Web\Data\ResponseFrom::CURL); $response->isSuccessful(); // true for 2xx
Available Utilities
Content Utility
Fetch and interact with web page content.
Ping Utility
Ping hosts and check latency.
URI Utility
Parse, build and manipulate URLs.
Exception Handling
All package exceptions extend Myerscode\Utilities\Web\Exceptions\WebUtilityException, which extends RuntimeException. This allows catching all package exceptions in one go:
use Myerscode\Utilities\Web\Exceptions\WebUtilityException; try { $content = $web->content()->content(); } catch (WebUtilityException $e) { // Handle any package exception }
License
The MIT License (MIT). Please see License File for more information.