SilverStripe 路由不起作用

SilverStripe routing not working

我在 SilverStripe 中创建了一些控制器和路由,但我无法访问这些路由。

http://localhost/silverstripe/teams or http://localhost/silverstripe/player 无效。

TeamController.php

class TeamController extends Controller {

    private static $allowed_actions = array(
        'players',
        'index'
    );

    public function index(SS_HTTPRequest $request) {
        // ..
    }

    public function players(SS_HTTPRequest $request) {
        print_r($request->allParams());
    }
}

config.yml

---
Name: mysite
After:
- 'framework/*'
- 'cms/*'
---
# YAML configuration for SilverStripe
# See http://doc.silverstripe.org/framework/en/topics/configuration
# Caution: Indentation through two spaces, not tabs
SSViewer:
  theme: 'simple'

Director:
  rules:
    'teams//$Action/$ID/$Name': 'TeamController'
    'player/': 'PlayerController'
    '': 'HomeController'

为什么路由不起作用?

将此转移到 routes.yml

Director:
  rules:
    'teams//$Action/$ID/$Name': 'TeamController'
    'player/': 'PlayerController'
    '': 'HomeController'