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

  • SEARCH
  • Home
  • 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 7544451
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T08:40:30+00:00 2026-05-30T08:40:30+00:00

In Zend Framework, is it possible to add functionality to the $this object used

  • 0

In Zend Framework, is it possible to add functionality to the $this object used within the controller?

I’m trying to create an API, defined by class files stored in a seperate folder. So would love to be able to go:

$userDetails = $this->api->user()->getDetails();

Is this possible?

  • 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-30T08:40:32+00:00Added an answer on May 30, 2026 at 8:40 am

    This is just a reference to the object instance so you just need to add methods and properties to the class in question. For example:

    class MyController extends Zend_Controller_Action
    {
       protected $api = null;
    
       public function init()
       {
          $this->api = new ApiClass();
       }
    
       public function indexAction()
       {
          $this->api->user()->details();
       }
    
    
    }
    

    Of course this probably isnt the best way to go about it. I would probably put the api as a bootstrap resource and in that case youd do:

    class MyController extends Zend_Controller_Action
    {
    
       public function indexAction()
       {
          $this->getApi()->user()->details();
       }
    
       public function getApi()
       {
          return $this->getInvokeArg('bootstrap')->api;
       } 
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Zend Framework - multiplate navigation blocks I'm trying to make breadcrumbs render
Is it possible to call the member function of another controller in zend framework,
I'm pretty sure this is not possible in Zend Framework (I have searched the
I'm using the Zend Framework to create an API I want to use apache
I'm trying to follow Zend Framework's conventions as much as possible. In my application,
Is it possible to create a wildcard match using the Zend Framework Zend_Controller_Router_Route_Hostname for
Possible Duplicate: Zend Framework: Controller Plugins vs Action Helpers I know what the difference
Is it possible to create a router in Zend Framework that can match hostnames
I am using the Zend Framework. I have a controller named 'UserController' that has
Is it possible to integrate Zend Framework with already existing legacy web application? The

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.