robin73's avatar

Getting the PHP Practitioner Source Code to Work

I want to play around with the code from the PHP-Practitioner course hosted on Github here: https://github.com/laracasts/The-PHP-Practitioner-Full-Source-Code. However I have run into a few problems.

I cloned the repo and ran composer install then visited the folder's index.php in Chrome.

The first error was from line 67 of core/Router about Exception not existing. So I added a backslash (\Exception) and that seemed to fix that problem. But now I'm getting

Uncaught Exception: No route defined for this URI. in C:\Program Files (x86)\Ampps\www\dev\The-PHP-Practitioner-Full-Source-Code\core\Router.php on line 67

At this point I'm out of my depth.

Could someone please tell me what I need to do to get the project to work (other than simply watching the videos, which I am already doing)?

I'm guessing the problem is that the project is in a subdirectory of my web root (which is C:\Program Files (x86)\Ampps\www). I've tried prepending the path to the routes in the routes.php file but that didn't work either....

0 likes
1 reply
princelionelnzi's avatar

Try @armanway answer to this question:

For some reason array_key_exist doesn't work for me like it is for Jeff. So i tried this to find matching route for uri , and its working

foreach ($this->routes[0] as $routeName => $controllerPath) {
    if ($routeName === $uri) {
               return $controllerPath;
        }
}

The thing is that you cant find matching route with array_key_exist so it goes to next line where you trowed that exception.

good luck !

1 like

Please or to participate in this conversation.