Skip to content

Conversation

@Sagmedjo
Copy link

@Sagmedjo Sagmedjo commented Dec 6, 2025

This PR adds support for a configurable name_prefix for all Fortify routes.

Why

  • Enables clean usage of Fortify inside auth route groups.
  • Prevents route name collisions.
  • Produces clean, separated imports with Laravel Wayfinder.

Wayfinder Example

Config:

'name_prefix' => 'auth',

Before:

import { store } from '@/routes/login'; import { request } from '@/routes/password';

After:

import { store } from '@/routes/auth/login'; import { request } from '@/routes/auth/password';

Implementation

  • Adds name_prefix to the Fortify config and stub.
  • Applies it via the as option on the Fortify route group.
  • Normalizes formatting using Str.

Compatibility

  • Fully opt-in.
  • No breaking changes.
Copilot AI review requested due to automatic review settings December 6, 2025 22:52
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds a configurable name_prefix option to Fortify that allows prefixing all route names, enabling cleaner integration with grouped routes and preventing route name collisions, particularly useful for tools like Laravel Wayfinder.

Key Changes:

  • Added name_prefix configuration option with default empty string value
  • Applied the prefix to Fortify's route group using the as parameter
  • Updated documentation to describe the new route name prefix feature

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
config/fortify.php Adds the name_prefix configuration option with an empty string default
stubs/fortify.php Adds name_prefix config and updates documentation to explain the route name prefix feature
src/FortifyServiceProvider.php Implements the name prefix logic by retrieving the config value, normalizing it with Str::finish(), and applying it to the route group's as parameter

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +162 to +163
$as = config('fortify.name_prefix', '');
$as = $as !== '' ? Str::finish($as, '.') : '';
Copy link

Copilot AI Dec 6, 2025

Choose a reason for hiding this comment

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

The name_prefix configuration option lacks test coverage. Consider adding a test that verifies route names are properly prefixed when name_prefix is configured. For example, a test could:

  1. Set config(['fortify.name_prefix' => 'auth'])
  2. Register routes via the service provider
  3. Assert that route('auth.login') exists and routes are properly namespaced
Copilot uses AI. Check for mistakes.
@taylorotwell
Copy link
Member

Thanks for your pull request to Laravel!

Unfortunately, I'm going to delay merging this code for now. To preserve our ability to adequately maintain the framework, we need to be very careful regarding the amount of code we include.

If applicable, please consider releasing your code as a package so that the community can still take advantage of your contributions!

@Sagmedjo
Copy link
Author

Sagmedjo commented Dec 9, 2025

Hi, would be just good to know if this Feature is not wanted at all or if the PR was just not good enough.

Just afterwards I have seen, that tests in the starter kits would also have to be updated

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants