Add additional controller actions


I assume you will be now able to create a simplest application using zend  framework (Hope first post of this blog  First application in zend in 3 easy steps helpful to create that one).

Now in your indexController you have a indexAction, which is default calling as we create virtual host in httpd.conf (of apache web server ). But if you wants to create more actions in indexController and worried what to do, then below is one solution, as we are not using any editor(like zend studio of eclipse ), we can create new actions in Index controller through following command on your command prompt -

zf create action add Index
zf create action edit Index
zf create action delete Index

These commands create three new methods: addAction, editAction and deleteAction in IndexController and also create the appropriate view script files(see your /path/to/myproject/application/views/scripts/index there should 3 new .phtml files) .

You now have four actions in your controller.

You can test your work by insert following URLs in your browser.

http://localhost:8181/mywork --> leads you to index controller's index action
http://localhost:8181/index/add --> leads you to index controller's add action
http://localhost:8181/index/edit --> leads you to index controller's edit action
http://localhost:8181/index/delete --> leads you to index controller's delete action

( you have to write your own code in indexController for approtiate result in your add/edit/delete page :-D  )

7 comments:

  1. zend still suxx ...

    ReplyDelete
  2. How do you do it without zf? Just adding an action and a view file doesn't seem to work.

    ReplyDelete
    Replies
    1. Read first http://hello-zend.blogspot.com/2011/01/first-application-in-3-steps-first-zend.html

      Delete
    2. As compare to Zend Framework with Yii Framework, Which one do you consider is a better option.

      Delete
  3. WHAT PATH WE NEED TO SET in command prompt before executing these commands :
    zf create action add Index
    zf create action edit Index
    zf create action delete Index

    ReplyDelete
  4. Zend framework is my Favorite field work . Its really good to make framework for your website .
    Web development company in India | Managing Virtual Teams

    ReplyDelete