Skip to content

Commit 89fda9d

Browse files
committed
Bug fixed for controller method.
1 parent efa1009 commit 89fda9d

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/Router.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,10 @@ public function group($name, $settings = null, $callback = null)
349349
*/
350350
public function controller($route, $controller)
351351
{
352-
$controllerFile = realpath($this->paths['controllers'] . str_replace('\\','/',$controller) . '.php');
352+
$controller = str_replace(['\\', '.'], '/', $controller);
353+
$controllerFile = realpath(
354+
$this->paths['controllers'] . $controller . '.php'
355+
);
353356
if(file_exists($controllerFile)) {
354357
if(!class_exists($controller)) {
355358
$req = require($controllerFile);
@@ -358,6 +361,7 @@ public function controller($route, $controller)
358361
return $this->exception($controller . " controller file is not found! Please, check file.");
359362
}
360363

364+
$controller = str_replace('/', '\\', $controller);
361365
$classMethods = get_class_methods($this->namespaces['controllers'] . $controller);
362366
if($classMethods) {
363367
foreach ($classMethods as $methodName) {

0 commit comments

Comments
 (0)