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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T02:29:15+00:00 2026-06-01T02:29:15+00:00

I am using an aliased and namespaced class in a parent class successfully but

  • 0

I am using an aliased and namespaced class in a parent class successfully but it doesn’t seem to be available in the child class. The actual error is from the autoloader. The weird thing is that the function does work in the parent class and loads fine. How can I make a class brought in by use available in subclasses?

edit: the recipes are stateless — would it make sense to make them singletons in Base and then reference them as members in the child class MyTest?

I have the two files:

Base.php:

namespace selenium;
use selenium\recipe\Cms as Cms;
class Base extends \PHPUnit_Framework_TestCase
{
    public function __construct()
    {
        Cms::staticfunc(); //works fine
    } 
}

MyTest.php:

class MyTest extends \selenium\Base
{
    public testMyTest()
    {
        Cms::staticfunc(); //errors here 
    }
}
  • 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-06-01T02:29:16+00:00Added an answer on June 1, 2026 at 2:29 am

    From comment:

    i was hoping for a way to cascade the use without duplicating that line among the 20 or so child classes

    That is one of the biggest issues I have with PHP namespacing, that you have to call use for every file the current script needs access to. It’s the same situation we used to face having to call require_once 20 times on some scripts in order to bring in the necessary libraries.

    What I prefer to do is namespace my files (as they reside on the filesystem, like Zend Framework does) and use an autoloader to avoid the whole mess. I currently use ZF autoloader, which can be used outside of the framework, or you can also use the vanilla PHP implementation using SplAutoload.

    — Update —

    I have a library which I have written over the last few years which is namespaced as Hobis_Api, and are located on the filesystem with the same convention; ~/projects/projects/dp/hobis/lib/Hobis/Api/*. In order to register the namespace with Zend_Loader I do the following:

    // Be sure to set the include path to include the Zend and Hobis_Api files
    // Not sure how your setup is, but would look something like:
    set_include_path(get_include_path() . ':' . DIRNAME(__FILE__));
    
    require_once 'Zend/Loader/Autoloader.php';
    
    $autoloader = Zend_Loader_Autoloader::getInstance();
    $autoloader->registerNamespace(
        array(
            'Hobis_Api_'
        )
    );
    

    Normally the above code would go into some bootstrap file, which you can call from a centralized script in order to register the autoloader, once.

    Now, if your include path is set correctly, anytime you reference Hobis_Api_* it will be autoloaded for you, so you don’t need to call use or require_once, example usage:

    // SomeScript.php
    
    // Notice no requires
    
    // I can make a call to Hobis_Api_Image without error
    $image = Hobis_Api_Image;
    $image->setHeight(400);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here's my issue, I'm using a namespace to remove ambiguity from a factory class
I am trying to smooth text rendering using anti-aliasing. But it's not anti-aliased. First
Using C#, I need a class called User that has a username, password, active
I have a mut.cs as follows. using System; namespace ns { public class Arith
I am using the Python 2.7 runtime with NDB from the 1.6.2 SDK on
I am trying to build a python module (scikit.timeseries) using python setup.py build but
I'm using the most recent PI-OLEDB library to read data from aggregate views in
I am using Devise for authentication, so I've aliased a few columns in my
I am using Devise for authentication, so I've aliased a few columns in my
Using the following query, WITH cteTest (Employee_ID) AS ( SELECT employee_ID FROM pep.dbo.labor_ticket )

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.