The prefix method is located in the Illuminate\Routing\Router class.
The absolute path in a typical Laravel 5 application would be:
vendor/laravel/framework/src/Illuminate/Routing/Router.php
How to find it?
You probably know that when you write Route:: you are actually using the Laravel facade called Route. From there you can find the facade class reference in the official documentation of Laravel 5.4 at https://laravel.com/docs/5.4/facades#facade-class-reference. Here is the line you are looking for:
---------------------------------------------------------------
|Facade |Class                     |Service Container Binding |
---------------------------------------------------------------
|Route  |Illuminate\Routing\Router |router                    |
---------------------------------------------------------------
The flow
- The (protected) prefixmethod is handled by the__call@Router.return (new RouteRegistrar($this))->attribute($method, $parameters[0]);is executed
- the attribute@RouteRegistrarmethod is called and the element'prefix' => 'home'is added to the$this->attributesarray
- Since the attribute@RouteRegistrarmethod returns$this, thegroup@RouteRegistrarmethod is called
- The group@RouteRegistrarmethod calls thegroup@Routermethod
- The loadRoutes@Routermethod is called. It will parse all routes present in the closure, i.e.Route::get('/test', ...);
- This time the getmethod is called on the class underlying theRoutefacade, theRouterclass. Theget@Routermethod is executed
- addRoute@Routeris called, which in turn calls the- createRoute@Routermethod
- createRoute@Routercalls- newRoute@Routerwith the prefixed URI as second argument
You will notice that the prefix@Router method calls getLastGroupPrefix@Router which obviously retrieve the prefix of the last group.