# \`Router::scope()\` is deprecated, use the non-static method \`RouteBuilder::scope()\` instead

**URL:** <https://discourse.cakephp.org/t/router-scope-is-deprecated-use-the-non-static-method-routebuilder-scope-instead/10834>\
**Category:** Need Help\
**Created:** [December 19, 2022, 12:10pm UTC](https://discourse.cakephp.org/t/router-scope-is-deprecated-use-the-non-static-method-routebuilder-scope-instead/10834 "2022-12-19T12:10:11Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![peterg](https://avatars.discourse-cdn.com/v4/letter/p/977dab/32.png) [@peterg](https://discourse.cakephp.org/u/peterg)\
**Post date:** [December 19, 2022, 12:10pm UTC](https://discourse.cakephp.org/t/router-scope-is-deprecated-use-the-non-static-method-routebuilder-scope-instead/10834/1 "2022-12-19T12:10:11Z")

</div>

Hi, I’m seeing this error after migrating to 4.4.7, but have absolutely no idea what I do about it. The relevant bit of code in routes.php is shown below. I have commented out the reference to a galleries controller as I no longer have this controller. Can someone point me in the right direction please?

Router::scope(‘/’, function (RouteBuilder $routes) {

```
/**
 * Apply a middleware to the current route scope.
 * Requires middleware to be registered via `Application::routes()` with `registerMiddleware()`
 */

```

// $routes-\>applyMiddleware(‘csrf’);

```
/**
 * Here, we are connecting '/' (base path) to a controller called 'Pages',
 * its action called 'display', and we pass a param to select the view file
 * to use (in this case, src/Template/Pages/home.ctp)...
 */
$routes->connect('/', ['controller' => 'Pages', 'action' => 'display', 'index']);

```

/_Router::connect('/gallery/_',  
array(‘controller’ =\> ‘galleries’, ‘action’=\>‘index’)); \*/

````
/**
 * ...and connect the rest of 'Pages' controller's URLs.
 */
$routes->connect('/pages/*', ['controller' => 'Pages', 'action' => 'display']);

/**
 * Connect catchall routes for all controllers.
 *
 * Using the argument `DashedRoute`, the `fallbacks` method is a shortcut for
 *
 * ```
 * $routes->connect('/:controller', ['action' => 'index'], ['routeClass' => 'DashedRoute']);
 * $routes->connect('/:controller/:action/*', [], ['routeClass' => 'DashedRoute']);
 * ```
 *
 * Any route class can be used with this method, such as:
 * - DashedRoute
 * - InflectedRoute
 * - Route
 * - Or your own route class
 *
 * You can remove these routes once you've connected the
 * routes you want in your application.
 */
$routes->fallbacks(DashedRoute::class);

````

});

---

<div class="post-metadata">

**Author:** ![KevinPfeifer](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/kevinpfeifer/32/3365_2.png) [@KevinPfeifer](https://discourse.cakephp.org/u/KevinPfeifer)\
**Post date:** [December 19, 2022, 12:17pm UTC](https://discourse.cakephp.org/t/router-scope-is-deprecated-use-the-non-static-method-routebuilder-scope-instead/10834/2 "2022-12-19T12:17:36Z")

</div>

See [https://github.com/cakephp/app/blob/4.x/config/routes.php](https://github.com/cakephp/app/blob/4.x/config/routes.php)

---

<div class="post-metadata">

**Author:** ![peterg](https://avatars.discourse-cdn.com/v4/letter/p/977dab/32.png) [@peterg](https://discourse.cakephp.org/u/peterg)\
**Post date:** [December 19, 2022, 12:53pm UTC](https://discourse.cakephp.org/t/router-scope-is-deprecated-use-the-non-static-method-routebuilder-scope-instead/10834/3 "2022-12-19T12:53:45Z")

</div>

Magic! Fixed it, thank you.
