Skip to content

fix(laravel): honor path_segment_name_generator config for url segments#8251

Merged
soyuka merged 1 commit into
api-platform:4.3from
soyuka:fix/laravel-dash-segment-config-7244
Jun 5, 2026
Merged

fix(laravel): honor path_segment_name_generator config for url segments#8251
soyuka merged 1 commit into
api-platform:4.3from
soyuka:fix/laravel-dash-segment-config-7244

Conversation

@soyuka
Copy link
Copy Markdown
Member

@soyuka soyuka commented Jun 5, 2026

Summary

The Laravel provider hard-bound PathSegmentNameGeneratorInterface to UnderscorePathSegmentNameGenerator, so setting api-platform.path_segment_name_generator (e.g. to DashPathSegmentNameGenerator::class) had no effect. Routes always used underscores. Now the binding resolves from config with the underscore generator as the default, preserving prior behavior.

Reproduction

Set 'path_segment_name_generator' => DashPathSegmentNameGenerator::class in config/api-platform.php — a resource named ProductOrder still routed as /product_orders instead of /product-orders.

Test plan

  • Added failing tests for the dash override + default underscore behavior.
  • Tests pass after the fix.
  • Laravel suite green for changed paths.

Fixes #7244

ApiPlatformProvider hard-coded UnderscorePathSegmentNameGenerator,
ignoring any user override. Bind the interface through a closure that
reads the api-platform.path_segment_name_generator config key (default
UnderscorePathSegmentNameGenerator preserves prior behavior). Allows
switching to DashPathSegmentNameGenerator for dasherized segments.

Fixes api-platform#7244
@soyuka soyuka merged commit b5c41af into api-platform:4.3 Jun 5, 2026
109 of 112 checks passed
@soyuka soyuka deleted the fix/laravel-dash-segment-config-7244 branch June 5, 2026 11:56
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