otis22 / vetmanager-url
Vetmanager - CRM for veterinary. All vetmanager clients has access to their crm via URL. Now Vetmanager is changing server architecure and URL can changes. This project for getting full URL by only first part. Use this library avoid hardcode.
Requires
- php: ^7.4 | ^8.0
- ext-json: *
- elegant-bro/interfaces: ^1.1
Requires (Dev)
- guzzlehttp/guzzle: ^6.5 || ^7.0
- otis22/php-coverage-checker: ^1.2
- php-coveralls/php-coveralls: ^2.2
- phpstan/phpstan: ^0.12.19
- phpunit/phpcov: ^8.0
- phpunit/phpunit: ^9.1
- squizlabs/php_codesniffer: 3.*
- wapmorgan/php-deprecation-detector: ^2.0
Suggests
- guzzlehttp/guzzle: ^6.5 || ^7.0: optional HTTP client injection for custom headers, timeouts and transport configuration
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-09-14 14:09:05 UTC
README
Vetmanager Url
Vetmanager - CRM for veterinary. All vetmanager clients has access to their crm via URL. Now Vetmanager is changing server architecure and URL can changes. This project for getting full URL by only first part. Use this library avoid hardcode.
Now url address has format $domain.vetmanager.ru for example: myclinic76.vetmanager.ru, but it url format will be change.
Vetmanager REST API in Postman
How to use
Installation
composer require otis22/vetmanager-url
Examples
use function Otis22\VetmanagerUrl\url; /* return Url object, which can be convert to string with full url address https://$domain.vetmanager.ru */ echo url('myclinic')->asString();
Where 'myclinic' is first part from your clinic url. $domain.vetmanager.ru and "vetmanager.ru" is a variable
Optional HTTP client
Existing calls such as url('myclinic') continue to use PHP streams and do not
require Guzzle. To configure outgoing requests, install Guzzle 6.5 or 7:
composer require guzzlehttp/guzzle
Pass a GuzzleHttp\ClientInterface implementation as the optional client:
use GuzzleHttp\Client; use function Otis22\VetmanagerUrl\url; use function Otis22\VetmanagerUrl\url_test_env; use function Otis22\VetmanagerUrl\create_url_from_billing_api_gateway; $client = new Client([ 'headers' => ['User-Agent' => 'my-project/1.2.3'], 'connect_timeout' => 3, 'timeout' => 10, ]); echo url('myclinic', $client)->asString(); echo url_test_env('myclinic', $client)->asString(); echo create_url_from_billing_api_gateway( 'myclinic', 'https://billing-api.example', $client )->asString();
For direct factory use, the new method is
Url\FromJson::fromDomainAndBillingApiUsingClient($domain, $billingApi, $client).
The existing FromJson::fromDomainAndBillingApi($domain, $billingApi) method keeps
its original two-parameter signature and stream transport, including compatibility
with subclasses overriding it. All existing calls remain supported. Passing null
to the optional client argument of the helper functions uses the original path.
The library sends GET /host/<domain> through the supplied client. It does not
replace its headers, timeouts, proxy or middleware configuration. The library
does not invent a project name or version; the calling application owns them.
Transport exceptions propagate. HTTP responses with status 400 or higher are
rejected even when the client sets http_errors to false. Existing JSON and
billing-response validation still applies when asString() is called.
url() without a client keeps its existing in-process cache by domain. Calls
with an explicit client bypass that shared cache: each function call performs
a request, even for the same domain and client. This prevents an earlier lookup
from hiding a request made with another client's configuration. Keep the returned
Url object if you want to reuse the result; repeated asString() calls do not
send additional requests. url_test_env() and the custom-gateway factory remain
uncached. The new client-based factory normalizes trailing gateway slashes.
The original stream-based factory preserves its existing URL construction.
When another library calls these helpers, it must accept and forward the client from the application. Use a client configured for billing URL discovery, separate from the CRM client carrying clinic credentials. Installing this release alone does not add project headers to existing callers.
Contributing
The CI matrix tests the optional client with both Guzzle 6 and Guzzle 7. Guzzle 6.5.8 is tested only for legacy compatibility, using mock HTTP handlers. Known advisories for Guzzle 6.5.8 and its PSR-7 1.9.1 dependency are allowed only during dependency installation in those CI jobs and remain visible to audit. Live integration tests and coverage uploads run only with Guzzle 7. Live integration tests also require TEST_DOMAIN_NAME; forks without that secret explicitly skip them. This CI exception does not apply to consumer installations; use a current Guzzle 7 release for new integrations. The minimum supported PHP version remains 7.4. CI also verifies a production installation without Guzzle and runs unit tests in a fixed shuffled order.
For run all tests
make all
or connect to terminal
make exec
Dafault php version is 8.2. Use PHP_VERSION= for using custom version.
make all PHP_VERSION=8.0 # run both make all PHP_VERSION=7.4 && make all PHP_VERSION=8.0
For integration tests copy .env.example to .env and fill with yours values
all commands
# security check make security # composer install make install # composer install with --no-dev make install-no-dev # check code style make style # run static analyze tools make static-analyze # run unit tests make unit # check coverage make coverage # check integration, .env required make integration