-
-
Notifications
You must be signed in to change notification settings - Fork 63
Description
Proposed new feature or change
While learning my way around the Yii3 starter app, I found the naming of web entry points a bit confusing to follow. In the same project, we have two different styles for the same type of file:
HomePage: src/Web/HomePage/Action.php
NotFound: src/Web/NotFound/NotFoundHandler.php
As a new user, this made it difficult for me to tell what is a "framework requirement" and what is just a naming choice.
How this affects the learning curve:
"Is 'Action' a magic word?" When I see Action.php used repeatedly, my first thought is that the framework requires this specific name to work. It wasn't until I saw NotFoundHandler.php that I realized I could name these files whatever I wanted. Standardizing this would make it much clearer that these are just standard PHP classes.
Confusion in the Routing Logic The router uses ->action(Action::class). Seeing the word "action" used as a method, a class name, and a filename all at once made it hard for me to visualize the flow of data. Using a unique name like HomePageHandler makes it much easier to see the difference between the Router's command and my own code.
Difficulty Tracking Code While trying to understand how different pages connect, I found it hard to keep track of which file I was looking at. When my editor tabs all say Action.php, I have to keep checking the namespace just to remember which page's logic I'm editing.
The Suggestion: Follow the NotFoundHandler pattern
I think the NotFoundHandler approach is a much better "teaching tool" for the demo app. It shows exactly what the file is for and makes the routes.php file much easier to read without needing to alias every import.
Proposed Standard:
- Folder: src/Web/HomePage/
- Logic File: HomePageHandler.php (Descriptive and unique)
- View File: template.php