Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6095395
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T12:48:26+00:00 2026-05-23T12:48:26+00:00

I’ve read somewhere that using a base controller is bad and that there are

  • 0

I’ve read somewhere that using a base controller is bad and that there are more down sides than up sides. That person said that you should use plugins.

What I need is before every action get from the request the “lang” variable and pass it to the current action. What I’ve done now is making a base controller with preDispatch that gets it from the request and passes it through $this (any other controller extends from the base).

How should I implement it if I’d use plugins? And should I?

EDIT:
Found the place where I’ve read that base controllers are evil: Sending variables to the layout in Zend Framework comment on the last answer. Notice that my question is not similar (I need to pass to an action, not to the layout).

EDIT2:
With your answers on how to implement, could you also include an explanation why using a base controller is bad?

EDIT3:
Can’t seem to make it work. I’ve done: created a helpers dir in the controllers folder, added in the initializer Zend_Controller_Action_HelperBroker::addPath('../application/default/controllers/helpers/', 'Controller_Helper');
Created a file in that folder called LangHelper.php and created a class Controller_Helper_Lang extends Zend_Controller_Action_Helper_Abstract. Why doesn’t it yet work? (maybe I need to add a require once or something?)

EDIT4:
What I get is:

Zend_Loader_PluginLoader_Exception: Plugin by name ‘Lang’ was not
found in the registry; used paths: Controller_Helper_:
../application/default/controllers/helpers/;../application/admin/controllers/helpers/
Zend_Controller_Action_Helper_: Zend/Controller/Action/Helper/ in
C:\wamp\www\EfCom\library\Zend\Loader\PluginLoader.php on line 412

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T12:48:27+00:00Added an answer on May 23, 2026 at 12:48 pm

    You should rather use Action Helpers, not plugins.

    That way, you could do for example $this->_helper->getLang() to get the lang in your action (with GetLang being your Action Helper), rather than use a class attribute.

    Plugins are useful to control the routing of the request (for example to add ACL filtering). This is not what you want to do here.

    Example code for your helper:

    class MyModule_Controller_Helper_GetLang extends Zend_Controller_Action_Helper_Abstract {
        /**
         * direct() is the default method called
         * when you use $this->_helper->getLang()
         */
        public function direct() {
            $lang = /*get you lang here*/;
            return $lang;
        }
    }
    

    Tutorials:

    • http://www.phpbuilder.com/columns/zend-action-helpers/Jason_Gilmore091410.php3
    • http://tournasdimitrios1.wordpress.com/2011/04/24/zend-framework-a-basic-example-of-zend-controller-action-helper/

    I recommend to put your helpers in /application/controllers/helpers. See the official recommendation for directory layout. They say :

    controllers/helpers/ – These directories will contain action helpers. Action helpers will be namespaced either as “Controller_Helper_” for the default module or “Controller_Helper” in other modules.

    Update:
    I’ve used a base controller before knowing about action helpers, that does the job, but lets say helpers are there exactly for that. This is a concept created exactly for what you want to do, with some advantages (like lazy loading, so that the helper is loaded only when you use it). Imagine in a week you need to add another variable, but needed only in some pages, not all. With a base controller, those variables would be loaded every time. You should rather learn how to do it right (with helpers), so that you can use it fully later. That will keep you code clean and organized. A controller is just a controller, a helper is just a helper.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
We're building an app, our first using Rails 3, and we're having to build
I'm making a simple page using Google Maps API 3. My first. One marker
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I'm looking for suggestions for debugging... If you view this site in Firefox or
Seemingly simple, but I cannot find anything relevant on the web. What is the
Does anyone know how can I replace this 2 symbol below from the string

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.