PHPackages                             ejosterberg/opensalestax-sylius - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. ejosterberg/opensalestax-sylius

ActiveSymfony-bundle[Utility &amp; Helpers](/categories/utility)

ejosterberg/opensalestax-sylius
===============================

Sylius bundle: replace Sylius's built-in tax calculation with self-hosted OpenSalesTax — destination-based US sales tax.

v0.1.0-alpha.3(3w ago)05Apache-2.0PHPPHP &gt;=8.2CI passing

Since May 16Pushed 3w agoCompare

[ Source](https://github.com/ejosterberg/opensalestax-sylius)[ Packagist](https://packagist.org/packages/ejosterberg/opensalestax-sylius)[ Docs](https://github.com/ejosterberg/opensalestax-sylius)[ RSS](/packages/ejosterberg-opensalestax-sylius/feed)WikiDiscussions main Synced 1w ago

READMEChangelog (1)Dependencies (13)Versions (4)Used By (0)

opensalestax-sylius
===================

[](#opensalestax-sylius)

> Sylius bundle that replaces Sylius's built-in tax calculation with destination-based US sales tax computed by a self-hosted [OpenSalesTax](https://github.com/ejosterberg/open-sales-tax-website) engine.

[![CI](https://github.com/ejosterberg/opensalestax-sylius/actions/workflows/ci.yml/badge.svg)](https://github.com/ejosterberg/opensalestax-sylius/actions/workflows/ci.yml)[![License: Apache-2.0 OR GPL-2.0-or-later](https://camo.githubusercontent.com/ed720b8af292f8fbd2691e43ae8fe3480ef13c19f1352c55557d0d7aaf490d1f/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4170616368652d2d322e302532304f5225323047504c2d2d322e302d2d6f722d2d6c617465722d626c75652e737667)](LICENSE)[![PHP](https://camo.githubusercontent.com/efcf393b65eb2e11d0e6ac224a3f49b067afed7725c2b1aef10c69716b9ddec7/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f656a6f73746572626572672f6f70656e73616c65737461782d73796c6975732e737667)](composer.json)

Free, self-hostable, no per-transaction fees, no SaaS lock-in. The merchant runs both Sylius and the OpenSalesTax engine on their own infrastructure.

Status
------

[](#status)

**v0.1.0-alpha.1** — initial release. Single-line tax calculation through a Sylius `TaxCalculationStrategy`, USD/US gating, fail-soft engine error handling, optional per-state nexus filter.

Install
-------

[](#install)

```
composer require ejosterberg/opensalestax-sylius
```

Register the bundle in `config/bundles.php`:

```
return [
    // ...existing bundles...
    OpenSalesTax\Sylius\OpenSalesTaxSyliusBundle::class => ['all' => true],
];
```

Add a config file at `config/packages/opensalestax_sylius.yaml`:

```
opensalestax_sylius:
    engine_url:       '%env(OSTAX_ENGINE_URL)%'   # e.g. http://10.32.161.126:8080
    api_key:          '%env(default::OSTAX_API_KEY)%'
    timeout_seconds:  5.0
    fail_hard:        false
    default_category: general
    nexus_states:     []         # e.g. ['MN', 'WI']  — empty = collect everywhere
    cache_ttl_seconds: 3600
```

Then in Sylius admin (`Configuration → Channels →  → Tax Calculation Strategy`), select `OpenSalesTax`. Place a test order shipping to a US ZIP — destination-based tax appears on the order.

How it works
------------

[](#how-it-works)

1. Sylius invokes `OstaxTaxationStrategy::applyTaxes()` once per order during checkout recalculation.
2. The strategy reads the destination ZIP / state / currency / country off the order's shipping address.
3. For each `OrderItemUnit`, it asks `OstaxCalculator` for the tax amount. The calculator gates on USD-only, US-only, nexus-state filter, then calls the OST engine via `POST /v1/calculate`.
4. Per-unit tax is added as an adjustment of type `tax` labeled `OpenSalesTax`.

Cache: each (zip, category, cents) tuple is memoized in Symfony's `cache.app` PSR-6 pool for `cache_ttl_seconds` (default 1 hour).

Behavior matrix
---------------

[](#behavior-matrix)

Order shapeWhat happensUSD, US ship-to, valid 5-digit ZIP, in-nexusEngine called; tax adjustment addedNon-USD currency0.0 tax — Sylius's other strategies / built-in `TaxRate` rows handle itNon-US ship-to country0.0 tax (constitution §5)Missing or invalid ZIP0.0 tax`nexus_states` set + ship-to state not on list0.0 taxEngine unreachable, `fail_hard: false` (default)0.0 tax + warning loggedEngine unreachable, `fail_hard: true`Throws — surfaces as a Sylius checkout errorWhat this bundle does NOT do
----------------------------

[](#what-this-bundle-does-not-do)

- File or remit collected tax (calculation only — constitution §6)
- Validate addresses or autocomplete (out-of-scope §10)
- Handle non-USD currency or non-US ship-to (constitution §5)
- Validate exemption certificates against state DOR (§10)
- Marketplace-facilitator special handling (§10)
- Run a standalone HTTP / webhook server (constitution §2 — purely in-process; outbound calls to the engine only)

Configuration reference
-----------------------

[](#configuration-reference)

KeyTypeDefaultDescription`engine_url`string(required)Base URL of the OST engine. Must be `http://` or `https://`.`api_key`string|null`null`Optional API key (sent as `X-API-Key` header).`timeout_seconds`float`5.0`Per-request timeout.`fail_hard`bool`false`When `true`, engine errors throw and surface as Sylius errors. Default: fail-soft (return 0, log warning).`default_category`enum`general`OST category sent for line items with no per-product mapping. One of `general`, `clothing`, `groceries`, `prescription_drugs`, `prepared_food`, `digital_goods`.`nexus_states`string\[\]`[]`Allowlist of US state codes (e.g. `['MN', 'WI']`). Empty = collect everywhere.`cache_ttl_seconds`int`3600`Cache TTL for engine results. `0` disables caching.Compatibility
-------------

[](#compatibility)

SyliusOST engineThis bundle`^1.13``v0.14+` (v1 API)`0.1.x`License
-------

[](#license)

Dual-licensed under your choice of:

- [Apache License 2.0](LICENSE-APACHE.txt), OR
- [GNU GPL 2.0 or later](LICENSE-GPL.txt)

See [`LICENSE`](LICENSE) for the SPDX declaration. The dual licensing exists to keep the OpenSalesTax portfolio's licensing footprint consistent across ecosystems.

Contributing
------------

[](#contributing)

See [`CONTRIBUTING.md`](CONTRIBUTING.md). DCO sign-off required on every commit.

Disclaimer
----------

[](#disclaimer)

This bundle calculates US sales tax. It does not file returns, remit collected tax, or validate exemption certificates against state DOR systems. The merchant remains responsible for filing and remittance.

###  Health Score

36

—

LowBetter than 79% of packages

Maintenance95

Actively maintained with recent releases

Popularity5

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity34

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~2 days

Total

3

Last Release

21d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/b647ae9c341fdf92c36cb479ba7535c2eff9ac92f8614965a3b5953f7b543152?d=identicon)[ejosterberg](/maintainers/ejosterberg)

---

Top Contributors

[![ejosterberg](https://avatars.githubusercontent.com/u/6363457?v=4)](https://github.com/ejosterberg "ejosterberg (7 commits)")

---

Tags

symfonysyliusSymfony Bundletaxsales taxopensalestaxus-tax

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan, Psalm

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/ejosterberg-opensalestax-sylius/health.svg)

```
[![Health](https://phpackages.com/badges/ejosterberg-opensalestax-sylius/health.svg)](https://phpackages.com/packages/ejosterberg-opensalestax-sylius)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
