Answer the question
In order to leave comments, you need to log in
What is the best way to organize classes and methods?
There is a site with articles and the address of the article: web.com/art/artname
Where art is the section with articles, artname is the url of the article, it is also searched in the database. In the router it looks like this:
$class = $request->$controller.'.controller';
$obj = new $class;
$act = $obj->showArticle($request->action);
web.com/auth/login
will be automatically called by auth.controller, but then the problem is because there is no showArticle method in auth.controller, and it is hard-coded in the router. web.com/art/show/artname
web.com/art/edit/artname
web.com/auth/enter/login
$class = $request->$controller.'.controller';
$obj = new $class;
$act = $obj->$request->action($request->data);
web.com/artedit/artname
$class = $request->$controller.'.controller';
$obj = new $class;
$act = $obj->main($request->action);
if($controller == 'art'){
$act = $obj->showArticle($request->action);
}
elseif($controller == 'artedit') {
$act = $obj->edit($request->action);
}
Answer the question
In order to leave comments, you need to log in
Don't you think it's the bottom? Use a normal router and don't use path to controller garbage
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question