Yii Framework Forum: controller methods are not visible to yii2 - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

controller methods are not visible to yii2

#1 User is offline   parasporin 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 24
  • Joined: 09-October 13

Posted 18 June 2017 - 02:25 PM

If i add a new action method in a controller, yii can't 'see' it.

for example, if i place in the controller for view openAccess.php located in the view's site folder-

public function actionPublicAccess()
{
return $this->render('openAccess');
}

if i then place the below url in the browser
http://localhost/pat...te/PublicAccess
i get these errors:
2017-06-18 20:17:53 [127.0.0.1][-][f0238tg6ejclaupt4vrnlru6u4][trace][yii\web\Application::handleRequest] Route requested: 'site/PublicAccess'
2017-06-18 20:17:53 [127.0.0.1][-][f0238tg6ejclaupt4vrnlru6u4][trace][yii\base\Controller::runAction] Route to run: site/error
the same path works fine if i just replace publicAccess with about, login or contact- so the basic syntax is fine.

just started to use yii2 so perhaps doing something wrong that is really basic.

thanks
0

#2 User is offline   tri 

  • Elite Member
  • Yii
  • Group: Moderators
  • Posts: 1,824
  • Joined: 20-November 08
  • Location:Stockholm, Sweden

Posted 18 June 2017 - 04:56 PM

http://www.yiiframew...er-class-naming

http://www.yiiframew...reating-actions
Don't forget to read The Definitive Guide to Yii (1.1 en) (1.1 sv) (2.0 en) | The class reference (1.1) (2.0) has the details
0

#3 User is offline   Roberto Braga 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 190
  • Joined: 18-February 13
  • Location:Roma, Italy

Posted 19 June 2017 - 01:12 AM

If you successful got the about page actionAbout()

http://localhost/pat....php/site/about

you already have an hint on whats is wrong

Action name are CamelCase which are converted to all lowercase separated by '-' --> camel-case
So in for your action actionPublicAccess() try

http://localhost/pat...e/public-access
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users