Download the PHP package ux2dev/microinvest without Composer

On this page you can find all versions of the php package ux2dev/microinvest. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package microinvest

Microinvest PHP SDK

Warning: This is a developer testing version of the library -- use at your own risk.

The micro.bg backend is written against the Api_v1.4 PDF and has not yet been exercised against a live account.

Framework-agnostic PHP SDK for Microinvest, covering both of its APIs:

Backend API Reached via
Warehouse Pro REST Microinvest Utility Center on port 8700/8701, on premise
micro.bg signed RPC https://micro.bg/ExtApps/ExternalApp/API/, hosted

The two share a domain model (they sit on the same schema) but nothing on the wire, so each has its own config, transport and resources. What both support - partners, items, groups, VAT groups, payment types, objects, quantities - is expressed as Ux2Dev\Microinvest\Contracts\Client, so nomenclature code can be written once and pointed at either.

Works with plain PHP or Laravel.

Requirements

Installation

Enabling the API

  1. Open port 8700 in the firewall of the machine running Microinvest Utility Center.
  2. In Microinvest Utility Center pick Microinvest API from the module list.
  3. (Optional) Generate an API key in the settings and pass it as apiKey. If you skip this, the API is reachable anonymously.

Quick Start

Plain PHP

Plain PHP, micro.bg

Register the application first: sign in as owner, Администриране → Връзка с ел. магазини → Регистриране на ново приложение, type Външни приложения, status active. The Настройки link on that row reveals the two credentials and lets you pick the user whose permissions the API calls run as.

Laravel

Configuration

WarehouseProConfig

Every Warehouse Pro client takes a WarehouseProConfig. It is a final readonly value object: all inputs are validated at construction, the API key is private and redacted from var_dump(), and serialization is blocked.

Each Microinvest install is its own on-premise host, so baseUrl is per-machine. The API key (when set) is sent as the X-API-Key header on every request.

Laravel configuration

Publish the config file:

This creates config/microinvest.php:

Each connection declares a driver: warehouse_pro or micro_bg. MicroinvestManager::client() returns Contracts\Client; type-hint the concrete client when you need a backend's extras.

Multiple connections

Add more entries under connections and switch at runtime:

connection() returns an immutable clone; the default connection stays untouched.

How the SDK is organised

Layer Location Purpose
Config Ux2Dev\Microinvest\WarehousePro\WarehouseProConfig Base URL + optional API key, validated
Config Ux2Dev\Microinvest\MicroBg\MicroBgConfig API id + secret key + entry point, validated
Transport Ux2Dev\Microinvest\WarehousePro\WarehouseProTransport PSR-18 dispatch, query/body building, error mapping
Transport Ux2Dev\Microinvest\MicroBg\MicroBgTransport Signed RPC dispatch over one entry point
Signing Ux2Dev\Microinvest\MicroBg\RequestSigner json → base64 → urlencode → HMAC-SHA256
Envelope Ux2Dev\Microinvest\MicroBg\Envelope Reads {status\|success, errors[], data}
Input DTOs Ux2Dev\Microinvest\Dto\Input\{Group}\{Entity}Input Mutation bodies; toWarehouseProArray() emits snake_case wire keys
Result DTOs Ux2Dev\Microinvest\Dto\Result\{Group}\{Entity}Result Typed rows; fromWarehousePro() hydrates responses
Resources Ux2Dev\Microinvest\{WarehousePro,MicroBg}\Resources\{Group} One method per API action
Root clients WarehousePro\WarehouseProClient, MicroBg\MicroBgClient Aggregators exposing every resource
Contracts Ux2Dev\Microinvest\Contracts\* What every Microinvest backend supports
Laravel Ux2Dev\Microinvest\Laravel\* Service provider + multi-connection manager + facade

Resource methods come in three shapes:

Resources

Resource Methods
items() list, get, create, update, groups
partners() list, get, create, update, groups
users() list, groups
locations() list, groups
operations() list, get, create
store() list
payments() list, get, create, types
documents() list, get, create
vatGroups() list

Filtering & pagination

Collections accept exact-value filters as named arguments. A * in a string value triggers a LIKE search (e.g. name: 'Cola*'). Paging uses page / pageSize arguments (default page size 500); the response's X-CurrentPage / X-TotalPages headers are surfaced on the returned list.

Every list() method also takes a trailing filters: array as an escape hatch for any wire field the named arguments don't cover (the Microinvest API can filter "quite all collections by the exact value name"). Keys are raw snake_case wire names, and they override a colliding named argument:

Response paging is surfaced on the returned list:

Iterating everything

partners() and items() implement Ux2Dev\Microinvest\Contracts\PartnerRepository / ItemRepository, whose each() walks the whole nomenclature one page at a time:

It is a generator - rows are fetched lazily, so memory stays flat regardless of how many pages the server reports.

Ux2Dev\Microinvest\Contracts\Client is the interface every Microinvest backend satisfies. Type-hint it when your code only needs the nomenclature; type-hint a concrete client when you need that backend's extras.

Which backend supports what

Warehouse Pro micro.bg
partners() / items() - get, create, update, each yes yes
listItemGroups, listPartnerGroups, listTaxGroups, listPaymentTypes, listObjects, listQuantities yes yes
partners()->delete(), items()->delete() - yes
groups()->create/rename/delete - yes
items()->prices(), additional item codes - yes
users(), documents(), payments()->list/get/create yes -
invoices()->create() (returns a PDF url) - yes
company()->get(), company()->bankAccounts() - yes
operations()->allocateCost() - yes
Operations flat row per line document with nested lines

Anything in a - cell simply does not exist on that client, so reaching for it is a TypeError at the call site rather than a runtime surprise.

Operations are the one place the two backends model the same thing differently, which is why they are absent from the contract: Warehouse Pro returns one flat OperationResult per item line, while micro.bg returns an OperationDocumentResult header carrying OperationLineResult children. Code that pushes sales has to pick a backend.

Idempotent writes on micro.bg

micro.bg lets an integration stamp its own id on an operation and then work by that id, which makes re-running a sync safe:

Exceptions

All SDK exceptions extend Ux2Dev\Microinvest\Exception\MicroinvestException:

Exception When it is thrown
ConfigurationException Invalid config input, unknown connection or driver, a call missing a required identifier, or an attempt to serialize a config
TransportException PSR-18 client failure (network error, timeout)
InvalidResponseException Empty body, malformed JSON, unexpected shape
ApiException HTTP non-2xx. Carries httpStatus, apiCode, apiMessage, and the decoded body.

Testing

The suite mocks a PSR-18 client to exercise every resource method end-to-end.

License

MIT


All versions of microinvest with dependencies

PHP Build Version
Package Version
Requires php Version ^8.3
ext-json Version *
psr/http-client Version ^1.0
psr/http-factory Version ^1.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package ux2dev/microinvest contains the following files

Loading the files please wait ...