Skip to content

Upgrade to Sylius 2#7

Open
loevgaard wants to merge 6 commits into2.xfrom
upgrade
Open

Upgrade to Sylius 2#7
loevgaard wants to merge 6 commits into2.xfrom
upgrade

Conversation

@loevgaard
Copy link
Copy Markdown
Member

Summary

  • PHP >=8.2, Symfony ^6.4 || ^7.4, sylius/* ^2.0. Replaces setono/code-quality-pack + Psalm with setono/sylius-plugin: ^2.0 and PHPStan.
  • Resources moved from src/Resources/{config,translations,views} to repo-root config/, translations/, templates/. Bundle getPath() + getConfigFilesPath() overrides keep Sylius's resource registration finding the relocated Doctrine mapping.
  • Admin product tab is now driven by Twig hooks (sylius_admin.product.{update,create}.content.form.{side_navigation,sections}) — auto-loaded via the bundle's prepend(). ProductFormMenuSubscriber removed; ProductTypeExtension kept (Sylius 2 core itself uses form extensions for sections like channel_pricing).
  • priceTiers field switched to Symfony\UX\LiveComponent\Form\Type\LiveCollectionType so add/delete fire server-side via Live Components — same pattern Sylius admin uses for product images. Section template renders form_widget(button_add) / form_widget(button_delete).
  • tests/Application/ updated in place against Setono/SyliusPluginSkeleton: minimal kernel, refreshed bundles.php (incl. SyliusTwigHooksBundle), full config/packages swap, test entity moved to tests/Application/Entity/Product.php with a doctrine.orm.mappings block.
  • CI rewritten on top of setono/sylius-plugin/<job>@v2 composite actions (PHP 8.2/8.3/8.4 × Symfony 6.4/7.4 × lowest/highest); standalone BC workflow folded into build.yaml.

See UPGRADE.md for the full breakdown of breaking changes.

Test plan

  • composer update -W resolves on Symfony 7.4 + Sylius 2.2.5
  • composer check-style (ECS) passes
  • composer analyse (PHPStan level max) passes
  • composer phpunit (2 tests, 13 assertions) passes
  • bin/console lint:container / lint:yaml config / lint:twig templates clean
  • bin/console doctrine:schema:create + doctrine:schema:validate --skip-sync clean
  • Admin login → product update page renders the "Price tiers" tab via Twig hooks
  • Add price tier (Live Component action) creates a new row server-side; Save persists
  • Form re-renders saved tiers on reload (round-trip)
  • Per-row Delete (Live Component action) removes the row; Save persists deletion
  • Order-processor end-to-end: 5 units of a variant priced 2626 cents at qty=5/disc=10% tier yields five order_unit_promotion adjustments with originCode=tier_pricing totalling -1313 cents (correct ceiling-rounded distribution)
  • CI matrix green across PHP 8.2/8.3/8.4 × Symfony 6.4/7.4 (will run on push)

Bump PHP to >=8.2, Symfony to ^6.4 || ^7.4, sylius/* to ^2.0. Replace
setono/code-quality-pack + Psalm with setono/sylius-plugin: ^2.0 and
PHPStan; relocate src/Resources/{config,translations,views} to root
config/ + translations/ + templates/; rebuild the admin product tab on
Twig hooks (sylius_admin.product.{update,create}.content.form.{side_navigation,sections});
switch the priceTiers field to LiveCollectionType so add/delete fire
server-side via Symfony UX Live Components; bring tests/Application/
in line with Setono/SyliusPluginSkeleton; rewrite CI on top of the
setono/sylius-plugin/<job>@v2 composite actions.

See UPGRADE.md for the full breakdown.
@codecov
Copy link
Copy Markdown

codecov Bot commented May 4, 2026

Codecov Report

❌ Patch coverage is 16.66667% with 45 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (2.x@0bc3ec0). Learn more about missing BASE report.

Files with missing lines Patch % Lines
...encyInjection/SetonoSyliusTierPricingExtension.php 11.76% 30 Missing ⚠️
src/Form/Type/PriceTierCollectionType.php 0.00% 6 Missing ⚠️
src/SetonoSyliusTierPricingPlugin.php 0.00% 4 Missing ⚠️
src/Form/Type/PriceTierType.php 0.00% 3 Missing ⚠️
src/Form/Extension/ProductTypeExtension.php 0.00% 2 Missing ⚠️
Additional details and impacted files
@@          Coverage Diff           @@
##             2.x       #7   +/-   ##
======================================
  Coverage       ?   40.81%           
  Complexity     ?       67           
======================================
  Files          ?       10           
  Lines          ?      245           
  Branches       ?        0           
======================================
  Hits           ?      100           
  Misses         ?      145           
  Partials       ?        0           

☔ View full report in Codecov by Sentry.
📢 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.

CLAUDE.md: rewrite Architecture/Wiring/Conventions for the v2 layout
(repo-root config/, getConfigFilesPath override, Twig hooks,
LiveCollectionType + empty_data requirement, ORM 3 attribute mappings,
sylius.distributor.integer rename); switch default-PR-branch note
from master to 1.x and active dev to 2.x.

README.md: add requirements table, install steps (bundles.php, resource
override, doctrine migration), and a "How it works" section.

UPGRADE.md: document the LiveCollectionType + empty_data round-trip,
the getConfigFilesPath() override, ProductTrait's PHPDoc -> attribute
conversion, the sylius.integer_distributor -> sylius.distributor.integer
rename, and the PHP 8.4 implicit-nullable signature sweep.
{
$builder->add('quantity', IntegerType::class, [
'label' => 'setono_sylius_tier_pricing.form.price_tier.quantity',
'empty_data' => '1',
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.

Why do we need empty_data?

'scale' => 7, // defined in src/Resources/config/doctrine/model/PriceTier.orm.xml
'scale' => 7, // defined in config/doctrine/model/PriceTier.orm.xml
'help' => 'setono_sylius_tier_pricing.form.price_tier.discount_help',
'empty_data' => '0.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.

Why do we need empty_data?

loevgaard added 2 commits May 4, 2026 15:17
Other-bundle config injected via prepend() should be a PHP array
literal, not a YAML file read from disk: static analysis catches
shape errors at compile time, the config lives next to the
template paths it references, and the extension stays testable
without filesystem fixtures.

Drops config/sylius_twig_hooks.yaml and the Yaml::parseFile() round
trip; calls $container->prependExtensionConfig('sylius_twig_hooks',
[...]) with the inlined hook map directly. Documents the convention
in CLAUDE.md.
Remove plugin-internal narrative (getPath/getConfigFilesPath rationale,
empty_data reasoning, tooling swap, CI rewrite, form-extension still
present). Keep only items a consumer must act on or be aware of:
composer constraints, Resources/ alias rename, template override
paths, App\Entity\Product mapping caveat, embedding outside admin,
removed class + service id, the implicit-nullable interface signature.
Comment thread tests/Application/.env
# 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_tier_pricing_%kernel.environment%?serverVersion=5.7
DATABASE_URL=mysql://root@127.0.0.1:3306/setono_sylius_tier_pricing_%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.

Do we need to add the default port?

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