2
votes

My controller name is api and I want to create an action update_user_infoAction(), but when I try to create an action zf create action update_user_info Api, I get an error :

Action names should be camel cased.

Here is my terminal command and output:

volition@volition-H61M-DS2:/var/www/Dashboard_check$ zf create action update_user_info Api

Note: PHPUnit is required in order to generate controller test stubs.
An Error Has Occurred
Action names should be camel cased.

Zend Framework Command Line Console Tool v1.11.10 Details for action "Create" and provider "Action" Action zf create action name controller-name[=Index] view-included[=1] module

Someone suggested that I use Zend Router but I am a newbie in Zend Framework so please suggest to me how I can create this action.

Note :- I do not want to change my action name

I am trying to create an action with an underscore. I've added this code to my bootstrap:

class Bootstrap extends Zend_Application_Bootstrap_Bootstrap 
{ 
    protected function _initDoctype() 
    { 
         $dispatcher = $front->getDispatcher();
         $dispatcher->setWordDelimiter(array('.', '-'))->setPathDelimiter(''); 
    } 
} 

However, when I do the following: zf create controller update_user_info, I still get the same error.

Update: As suggested by @emaillenin

I am Trying this now :

<?php
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
    protected function _initDoctype() 
    {
        $frontController = Zend_Controller_Front::getInstance();
        $dispatcher = $frontController->getDispatcher();
        $dispatcher->setWordDelimiter(array('-', '.', '_'));
    }
}

http://localhost/Dashboard_check/public/api/update_user_info

but again, it doesn't work as it works for

http://localhost/Dashboard_check/public/api/updateuserinfo

1

1 Answers

1
votes

In your bootstrap, add the following lines of code,

$frontController = Zend_Controller_Front::getInstance();
$dispatcher = $frontController->getDispatcher();
$dispatcher->setWordDelimiter(array('-', '.', '_'));

When you call www.example.com/api/update_user_info

the following function will be invoked.

public function updateUserInfoAction() {

}

Keep your view script for this action in update-user-info.phtml

References -

http://zend-framework-community.634137.n4.nabble.com/Question-about-underscores-in-controller-and-action-names-td656525.html

http://www.zfforums.com/zend-framework-general-discussions-1/general-q-zend-framework-2/underscore-action-name-1204.html

http://zend-framework-community.634137.n4.nabble.com/underscore-in-URL-td648359.html