How best to organize classes and methods?

Is there a website with articles and link to the article:
web.com/art/artname
Where art - section with articles artname - article url it is searching in the database. In the router it looks like this:
$class = $request->$controller.'.controller';
$obj = new $class;
$act = $obj->showArticle($request->action);

But then you want other functionality, such as authorization and address web.com/auth/login automatically called by auth.controller but then the problem because in the auth.no showArticle controller method, and it is hard-coded in the router.

Options:

1) to Increase a length of the URL for a section in which to indicate the action:
web.com/art/show/artname
web.com/art/edit/artname
web.com/auth/enter/login

Then you can do it clearly:
$class = $request->$controller.'.controller';
$obj = new $class;
$act = $obj->$request->action($request->data);


2. Implement all classes single main method by default, for example main and increase the number of classes without increasing section in the URL, edit the article, then, would be at web.com/artedit/artname
$class = $request->$controller.'.controller';
$obj = new $class;
$act = $obj->main($request->action);


3. Do branching if-statement in the router, a bad option in my opinion, you do not want to think about it ))
if($controller == 'art'){
 $act = $obj->showArticle($request->action);
}
elseif($controller == 'artedit') {
 $act = $obj->edit($request->action);
}
June 8th 19 at 16:32
3 answers
June 8th 19 at 16:34
Solution
You yourself do not think that this is the bottom? Use a router of some normal and not kostyla garbage path to controller
I have used klein router installed via composer, the issue is not the router, and how to build architecture on - shaniya commented on June 8th 19 at 16:37
Yes, the router that you have, and the front controller has sehardcore - Mohamed_Lind75 commented on June 8th 19 at 16:40
Yes , in the front controller must be a mistake, it should read about him - shaniya commented on June 8th 19 at 16:43
June 8th 19 at 16:36
Solution
my article, there will be questions, write
archive.li/bDirF
June 8th 19 at 16:38
Solution
Error architecture, put the other router where you will be able to more finely resolve these things

Find more questions by tags PHP