This package can be used to retrieve http status code of a particular url, as well as its headers.
- Easy to use.
- Lightweight, no dependencies.
- Can be configured easily with curl options.
This package only requires php curl and json extensions. PHP requirement is 5.4+.
Add muffeen/url-status
as a require dependency in your composer.json
file:
composer require muffeen/url-status
Refer to the example below:
use Muffeen\UrlStatus\UrlStatus;
$urlStatus = UrlStatus::get('http://www.example.com');
$httStatusCode = $urlStatus->getStatusCode();
$responseHeaders = $urlStatus->getResponseHeaders();
Extend your request by using curl options constants. The example below show how can you set a user agent for your request.
use Muffeen\UrlStatus\UrlStatus;
$urlStatus = UrlStatus::get('http://www.example.com', array(
CURLOPT_USERAGENT => '<user-agent-here>',
));
$httStatusCode = $urlStatus->getStatusCode();
$responseHeaders = $urlStatus->getResponseHeaders();
This package is open-sourced software licensed under the MIT license.