Skip to content

feat: add prefix option for authentication routes#1322

Open
dimtrovich wants to merge 3 commits intocodeigniter4:developfrom
dimtrovich:feat/prefix-options-to-routes
Open

feat: add prefix option for authentication routes#1322
dimtrovich wants to merge 3 commits intocodeigniter4:developfrom
dimtrovich:feat/prefix-options-to-routes

Conversation

@dimtrovich
Copy link
Copy Markdown

Description

This pull request adds the ability to prefix all authentication route paths using a new prefix option in the routes() method.

  • New prefix option: Allows you to define a common prefix for all authentication routes (default /)
  • Refactoring: Replaces the hard-coded route group ‘/’ with a configurable $prefix variable

Benefits of this change

  • Increased flexibility - Allows you to group auth routes under a single prefix (e.g., auth/login, auth/register)
  • Better organization - Facilitates the organization of routes in complex applications
  • Consistency - Complements the existing namespace and except options
  • Backward compatible - The default value / preserves the existing behavior

Usage example

// All routes will be prefixed with ‘auth’
service(‘auth’)->routes($routes, [‘prefix’ => ‘auth’]);

// Generates: auth/login, auth/register, auth/logout, etc.

Checklist:

  • Securely signed commits
  • Component(s) with PHPDoc blocks, only if necessary or adds value
  • Unit testing, with >80% coverage
  • User guide updated
  • Conforms to style guide

@michalsn
Copy link
Copy Markdown
Member

This makes sense. However, could we rename prefix to group? It would better align with the underlying method we use.

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.

2 participants