Skip to content

Upgrade plugin to support Sylius 2.x - #9

Open
loevgaard wants to merge 3 commits into
2.xfrom
upgrade/sylius-2
Open

loevgaard wants to merge 3 commits into
2.xfrom
upgrade/sylius-2

Conversation

@loevgaard

Copy link
Copy Markdown
Member

Upgrades the plugin to Sylius ^2.2 / Symfony ^6.4 || ^7.4 / PHP >= 8.2, following the Setono Sylius v1→v2 plugin upgrade playbook. Hard major upgrade — no Sylius 1.x BC layer. See UPGRADE.md.

What changed

  • Dependencies — PHP 8.2 floor; sylius/* ^2.2; symfony ^6.4 || ^7.4; doctrine/collections ^2. Adopted the setono/sylius-plugin dev meta-pack (replaces hand-pinned PHPStan/ECS/Rector/Infection).
  • File layout — src/Resources/{config,views,translations,public} → repo-root config/, templates/, translations/, public/; bundle getPath()/getConfigFilesPath() overrides.
  • Service config — all XML → PHP DSL with FQCN service ids + interface aliases. Fixed renamed order-modifier service ids.
  • Asset/UI injection — sylius_ui events (removed in Sylius 2) → sylius_twig_hooks; the wishlist toggle now auto-injects on the product page (sylius_shop.product.show.content.info.summary).
  • Shop UI — templates rewritten for the Sylius 2 Bootstrap 5 theme + Tabler icons.
  • Test app — tests/Application aligned with the Sylius 2 skeleton (bundles, packages, Kernel, index.php bitmask, webpack assets).
  • Tooling/CI/docs — phpstan.neon, infection.json5, setono/sylius-plugin@v2 composite-action workflow; new UPGRADE.md; updated README.md and CLAUDE.md.

Heads-up

require-dev pins api-platform/symfony: ~4.2.1 (not the skeleton's ^4.3.3) to work around an upstream api-platform 4.3 + symfony/type-info 7.4 incompatibility that otherwise prevents the test app from booting. Test-app only; not a runtime dep. Worth raising upstream / revisiting.

Verification

Static (PHP 8.2): PHPStan level max ✓, ECS ✓, Rector (UP_TO_PHP_82) ✓, 59 unit + 1 functional test ✓, lint:container/lint:twig/lint:yaml ✓, Doctrine schema validates.

Browser (Playwright, booted shop): toggle add/remove, wishlist index + show render (Bootstrap), PATCH update (quantity/note), add-wishlist-to-cart (correct total), item removal, voter grants owner, and guest→user conversion on login — all verified end-to-end.

Targets Sylius ^2.2, Symfony ^6.4 || ^7.4 and PHP >= 8.2, following the
Setono Sylius v1→v2 plugin upgrade playbook. This is a hard major upgrade
with no Sylius 1.x BC layer (see UPGRADE.md).

Highlights:
- composer: raise floors (PHP 8.2, sylius/* ^2.2, symfony ^6.4||^7.4,
  doctrine/collections ^2); adopt the setono/sylius-plugin dev meta-pack.
- File layout: move src/Resources/{config,views,translations,public} to the
  repo root (config/, templates/, translations/, public/); add bundle
  getPath()/getConfigFilesPath() overrides.
- Service config: convert all XML to the PHP DSL with FQCN service ids.
- Asset/UI injection: replace the removed sylius_ui events with Twig hooks;
  auto-inject the wishlist toggle on the product page.
- Shop UI: rewrite templates for the Sylius 2 Bootstrap 5 theme + Tabler icons.
- Test app: align tests/Application with the Sylius 2 skeleton.
- Tooling/CI/docs: phpstan.neon, infection.json5, setono/sylius-plugin@v2
  composite-action workflow; add UPGRADE.md; update README and CLAUDE.md.

require-dev pins api-platform/symfony to ~4.2.1 to work around an upstream
api-platform 4.3 / symfony-type-info 7.4 incompatibility (test-app only).
@codecov

codecov Bot commented Jun 22, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (2.x@7639768). Learn more about missing BASE report.

Additional details and impacted files
@@          Coverage Diff           @@
##             2.x       #9   +/-   ##
======================================
  Coverage       ?   62.23%           
  Complexity     ?      167           
======================================
  Files          ?       36           
  Lines          ?      511           
  Branches       ?        0           
======================================
  Hits           ?      318           
  Misses         ?      193           
  Partials       ?        0           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Comment thread .github/workflows/build.yaml Outdated
pull_request:
paths-ignore:
- "**/*.md"
push: ~

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Push on *.x

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 9edd285 — on.push now triggers only on *.x branches (matching the Sylius-mirrored branch versioning).

Comment thread config/services/controller.php Outdated
;

// Add product/variant to wishlist
$services->set('setono_sylius_wishlist.controller.add_to_wishlist', AddToWishlistAction::class)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this use the FQCN?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 9edd285 — the abstract parents now use FQCN ids (AddToWishlistAction::class / RemoveFromWishlistAction::class).

I kept the two concrete children (setono_sylius_wishlist.controller.add_product_to_wishlist, ...add_product_variant_to_wishlist, and the remove siblings) on their snake-cased ids on purpose: they're referenced by name in config/routes/shop.yaml, and since the same class is registered twice (product vs variant, differing only by the $className arg) the children can't share a single FQCN id. Happy to rename them too if you'd prefer, but that's a route-contract change.

Comment thread tests/Application/.env Outdated
# For a sqlite database, use: "sqlite:///%kernel.project_dir%/var/data.db"
# Set "serverVersion" to your server version to avoid edge-case exceptions and extra database calls
DATABASE_URL=mysql://root@127.0.0.1/setono_sylius_wishlist_%kernel.environment%?serverVersion=5.7
DATABASE_URL=mysql://root@127.0.0.1/setono_sylius_wishlist_%kernel.environment%?serverVersion=8.0

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
DATABASE_URL=mysql://root@127.0.0.1/setono_sylius_wishlist_%kernel.environment%?serverVersion=8.0
DATABASE_URL=mysql://root@127.0.0.1/setono_sylius_wishlist_%kernel.environment%?serverVersion=11.6.2-MariaDB

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 9edd285 — reverted to serverVersion=11.6.2-MariaDB. (I'd switched it to 8.0 only to match my local MySQL; the committed default should track your env.)

Comment thread tests/Application/.env.test Outdated
APP_SECRET='ch4mb3r0f5ecr3ts'

KERNEL_CLASS='Setono\SyliusWishlistPlugin\Tests\Application\Kernel'
KERNEL_CLASS='Acme\SyliusExamplePlugin\Tests\Application\Kernel'

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Revert

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch — that Acme namespace was copied verbatim from the skeleton's .env.test. Reverted to Setono\\SyliusWishlistPlugin\\Tests\\Application\\Kernel in 9edd285.

Comment thread phpunit.xml.dist Outdated
<php>
<env name="APP_ENV" value="test"/>
<env name="SHELL_VERBOSITY" value="-1"/>
<env name="KERNEL_CLASS" value="Setono\SyliusWishlistPlugin\Tests\Application\Kernel"/>

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Defined in .env.test

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 9edd285 — removed the redundant KERNEL_CLASS env from phpunit.xml.dist; it's resolved from .env.test (the functional suite still boots correctly).

Review fixes:
- build.yaml: trigger push only on *.x branches
- config/services/controller.php: use FQCN ids for the abstract
  AddToWishlistAction / RemoveFromWishlistAction parents (the concrete
  children keep their snake-cased ids — referenced in routes/shop.yaml)
- tests/Application/.env: serverVersion back to 11.6.2-MariaDB
- tests/Application/.env.test: fix KERNEL_CLASS namespace (Acme -> Setono)
- phpunit.xml.dist: drop redundant KERNEL_CLASS env (defined in .env.test)

Translations: add messages + flashes for da, sv, no, fi, de, fr, es, it,
nl, pl, pt, cs, hu, ro, uk (all locales now carry the toggle_wishlist key).
Coverage: add unit tests for previously-untested classes — WishlistIndexAction,
FirstWishlistRedirectAction, UserWishlistProvider, GuestWishlistProvider,
Twig\Extension, SelectWishlistsCommand and the guest->user conversion
subscriber (74 unit + 1 functional test now).

Meta files:
- .gitattributes: drop removed tools (psalm, composer-require-checker), add
  composer-dependency-analyser.php, rector.php, infection.json5, phpstan.neon
- .gitignore: ignore /.claude/
- README.md: point coverage/mutation badges at the 2.x branch (master is gone)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant