Go to file
R. Eric Wheeler 0b237d9189 Update .gitlab-ci.yml 2021-01-01 22:52:21 +00:00
examples initial commit 2017-10-01 11:31:31 -07:00
src/Sikofitt initial commit 2017-10-01 11:31:31 -07:00
tests/Sikofitt/Tests Added tests 2017-10-01 12:16:15 -07:00
.gitignore initial commit 2017-10-01 11:31:31 -07:00
.gitlab-ci.yml Update .gitlab-ci.yml 2021-01-01 22:52:21 +00:00
.php_cs initial commit 2017-10-01 11:31:31 -07:00
LICENSE initial commit 2017-10-01 11:31:31 -07:00
README.md initial commit 2017-10-01 11:31:31 -07:00
composer.json initial commit 2017-10-01 11:31:31 -07:00
grumphp.yml initial commit 2017-10-01 11:31:31 -07:00
header.txt initial commit 2017-10-01 11:31:31 -07:00
phpunit.xml.dist Added tests 2017-10-01 12:16:15 -07:00

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

GPL-3.0

Contribute

Go for it.