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 4012672
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T09:16:36+00:00 2026-05-20T09:16:36+00:00

i am developing a Rest Controller using Zend Framework and i have to use

  • 0

i am developing a Rest Controller using Zend Framework and i have to use an external php class in one of my action methods of the controller. How can i add this class or access it from my controller action method?

Do i need to write a custom library?

In my controller action method, iam fetching the polygon information from the database. Now i have an external php class that can validate whether a point is inside the polygon.

Googling on this issue, i found that we can write custom library classes for this sake. But iam unsure about this. So i want to know how can i include this external functionality in my controller action.
Please guide.

  • 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-20T09:16:37+00:00Added an answer on May 20, 2026 at 9:16 am

    The simplest approach would be to just include the class, e.g.

    class PolygonController …
        public function someAction()
        {
            include 'path/to/class/file.php';
            $pointLocation = new pointLocation;
    
            // do something $pointLocation;
        }
    

    You can probably load this file with Zend_Loader or the Autoloader as well, but since the class name does’t follow the Pear/ZF naming convention, the easiest is this. It doesn’t matter where you put the actual class file as long as it is accessible somehow.


    Since this is a third party class, you could extend it to make it match the ZF/Pear naming convention. Then place it into your library folder, so you can use the Autoloader:

    <?php
    include 'path/to/class/file.php';
    class My_PointLoader extends pointLoader {}
    

    This file would be placed in APPLICATION_ROOT/lib/My/PointLoader.php

    And in your bootstrap, register your "My_" namespace with

    $autoloader->registerNamespace('My_');
    

    Then you can do $pointLoader = new My_PointLoader; in your controller and the autoloader will take care of including the file.


    Or, when you want to add functionality or change the API of the class, aggregate it with an Adapter, e.g.

    <?php
    include 'path/to/class/file.php';
    class My_PointLoader_Adapter
    {
        protected $_pointLoader;
        public function __construct(pointLoader $pointLoader = NULL)
        {
            if($pointLoader === NULL) {
                $pointLoader = new pointLoader;
            }
            $this->_pointLoader = new pointLoader;
        }
        public function someAdapterMethod($foo)
        {
            $this->_pointLoader->someMethodInPointLoader($foo);
        }
        // … more methods
    }
    

    Then add the namespace prefix as shown above, so the Autoloader handles inclusion.

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

Sidebar

Related Questions

I'm going to be developing a REST-ful Web Service for a new public website.
I'm developing a client/server app that will communicate via rest. Some custom request data
I am working on developing a pair of libraries to work with a REST
Developing a .NET WinForms application: how can I check if the window is in
Developing websites are time-consuming. To improve productivity, I would code a prototype to show
Developing a heavily XML-based Java-application, I recently encountered an interesting problem on Ubuntu Linux.
Developing a website and just trying to get back into the swing of (clever)
Developing server side code i finally got my eyes X-crossed trying to write -
When developing a desktop application in .NET, is it possible to not require the
When developing whether its Web or Desktop at which point should a developer switch

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.