codeigniter4 / codeigniter4/CodeIgniter4

AutoRouterImproved extendability

Open
#7,364 4 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
PHP
Stars
6k
Forks
2k
Avg merge
1d 11h
Merged PRs (30d)
73

Description

In the current state, the `AutoRouterImproved` is not thought to be replaced by an App-Specific service and to be extended on.

>[kenjis](https://github.com/codeigniter4/CodeIgniter4/issues/5889#issuecomment-1476185230): Because it is better to implement the interface, not extending the class.

In my case, I need to change the controller & method name which is already implemented in the router.
Re-Implementing the `AutoRouterImproved` to do that seems kinda ridiculous.

Two approaches come to my mind:

1. The specific solution: Use the "parent" routers methods for finding the method and controller name, this prevents duplicate code and allows for a little app-specific behavior.
2. The generic solution: Make the auto routers replaceable by app-specific services
1. Optional: make both extendable, so we don't have to write ridiculous amounts of code for small changes.

Contributor guide

Open the contributing guide

Research direction

Start by reading AutoRouterImproved and the parent router methods it currently uses for finding the controller and method name. Compare the two proposed approaches: reusing parent-router behavior or making auto routers replaceable and extendable through app-specific services. Done requires a decided design and an implementation that supports changing the controller and method name without duplicating the router.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
backend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.