R. Eric Wheeler 0b237d9189 | ||
---|---|---|
examples | ||
src/Sikofitt | ||
tests/Sikofitt/Tests | ||
.gitignore | ||
.gitlab-ci.yml | ||
.php_cs | ||
LICENSE | ||
README.md | ||
composer.json | ||
grumphp.yml | ||
header.txt | ||
phpunit.xml.dist |
README.md
sikofitt/user-agent
Easily add a proper user agent to php projects that use Guzzle or Curl.
Composer
curl -LSs https://getcomposer.org/installer|php
composer.phar require sikofitt/user-agent:dev-master
Usage
<?php declare(strict_types=1);
require __DIR__.'/../vendor/autoload.php';
use Sikofitt\UserAgent\UserAgent;
// Simple default example
$userAgent = UserAgent::create();
// PHP/7.1-70110 (sikofitt/user-agent; Linux x86_64) PHP/7.1.10-1+ubuntu17.04.1+deb.sury.org+1; guzzlehttp/6.2.1 curl/7.52.1 (https://packagist.org/sikofitt/user-agent)
// If guzzle is not installed the user agent would be -
// PHP/7.1-70110 (sikofitt/user-agent; Linux x86_64) PHP/7.1.10-1+ubuntu17.04.1+deb.sury.org+1; (https://packagist.org/sikofitt/user-agent)
// Extending
$ua = new class extends UserAgent {
protected static $format = 'PHP/%d.%d.%d';
protected static $params = [
PHP_MAJOR_VERSION,
PHP_MINOR_VERSION,
PHP_RELEASE_VERSION
];
};
$userAgent2 = $ua::create();
// PHP/7.1.10
License
Contribute
Go for it.