SDK for PHP
The Novapost API SDK is the official PHP SDK (Software Development Kit) for integration with the Nova Post API. With this package, you can quickly and conveniently connect such Nova Post features to your PHP application as shipment creation, parcel tracking, and other services.
Features/Advantages:
Official Nova Post support — guaranteed relevance, stability, and developer assistance.
Compliance with modern PHP standards — compatibility with modern frameworks and libraries.
Flexibility and extensibility — replace logger, HTTP client, token storage.
Easy integration — installation via Composer, example usage included.
Useful Links:
Requirements
Requires — Runtime dependencies (required for production use):
php >= 8.0— the package requires PHP 8.0+.guzzlehttp/guzzle ^7.0— HTTP client for making requests.psr/container ^2.0— compatibility with PSR dependency containers.psr/log ^3.0— PSR-compliant logging interfaces.
Requires (Dev) — Dev dependencies (needed only for development/CI):
phpstan/phpstan ^2.1— static analysis.phpunit/phpunit ^9.6— unit tests.squizlabs/php_codesniffer ^3.13— code style/linting.vlucas/phpdotenv ^5.6— loading environment variables from.env.
Suggests: None
Provides: None
Conflicts: None
Replaces: None
Installation
To get started, install the SDK via Composer by running the following command:
Working with the SDK
Client Initialization
After installing the SDK, initialize the client using NovaPostApiFactory.
This allows you to quickly create a client for interacting with the Nova Post API.
Add the following example to your code:
SDK Method Example
SDK methods have the same names and parameters as the corresponding client API methods. To calculate shipment cost, use this example:
Advanced Features
The SDK allows you to replace standard services (logger, HTTP client, token storage, etc.) with your own implementations using the ContainerBuilder dependency container.
This is useful if you need to:
Integrate the SDK with your framework’s logging system.
Configure an HTTP client with custom parameters or middleware.
Use your own storage mechanism for JWT tokens.
To do this, pass your custom services to the client factory through ContainerBuilder.
Using ContainerBuilder
For more flexible configuration, you can use NovaDigital\NovaPost\DI\ContainerBuilder to customize different aspects of the client.
Available Service Overrides
With ContainerBuilder, you can override the following services:
Psr\Log\LoggerInterface
Custom logging
Psr\Http\Client\ClientInterface
Custom HTTP client configuration
NovaDigital\NovaPost\Storage\JwtTokenStorageInterface
Custom JWT token storage
NovaDigital\NovaPost\Http\ResponseHandlerInterface
Custom response processing
NovaDigital\NovaPost\Http\RetryHandlerInterface
Custom retry logic
PSR Compliance
The NovaPost API SDK complies with the following PSR standards, ensuring compatibility, modern design, and high code quality:
PSR-4: Autoloader
For class autoloading
PSR-11: Container Interface
For a flexible dependency container
PSR-3: Logger Interface
Allows using any compatible logger
PSR-7: HTTP Message Interface
Used for all API requests and responses
PSR-18: HTTP Client
For sending HTTP requests
PSR-17: HTTP Factories
For creating PSR-7 messages
PSR-12: Extended Coding Standard
For coding style
Following these standards makes the SDK reliable, predictable, and easy to integrate into any modern PHP application.
OK
No content
OK
No content
Last updated