Jump to:

22977 Posts in 11742 Topics by 2826 members

General Questions

SilverStripe Forums » General Questions » Problem with Controller not found

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 886 Views
  • ImacSS
    Avatar
    Community Member
    35 Posts

    Problem with Controller not found Link to this post

    Trying to make a Controller to handle custom exporting of data.
    Created a file CompetitionExport_Controller.php and placed into code directory.

    class CompetitionExport_Controller extends Controller
    {
       function index() {
          return $this->renderWith('CompetitionReport_Export');
       }
    }

    In the config file, I have defined this rule:

    Director::addRules(50, array(
       'compexp/$Action/$ID' => 'CompetitionExport_Controller'
    ));

    Yet when I go to the URL http://mysite/compexp/index/621 I receive the following error:
    Fatal error: Class 'CompetitionExport_Controller' not found in /sapphire/core/control/Director.php on line 274

    Can anyone provide me with what I'm doing wrong?
    Everything looks fine from what I can tell based upon this page: http://doc.silverstripe.org/controller

    This is with SS 2.3.2.

  • Sean
    Avatar
    Forum Moderator
    921 Posts

    Re: Problem with Controller not found Link to this post

    You need to add ?flush=1 or ?flush=all to the end of the URL, the class hasn't loaded yet...

    Also the controller should be in a file named "CompetitionExport.php" not "CompetitionExport_Controller.php".

    Cheers,
    Sean

  • ImacSS
    Avatar
    Community Member
    35 Posts

    Re: Problem with Controller not found Link to this post

    Oh man - forgot about the name of the file. That was my problem.

    Thanks for the answer Sean.

    886 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.