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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T04:55:23+00:00 2026-06-11T04:55:23+00:00

For my application I am using PSR-0 namespaces. Everything works beautiful! Until I wanted

  • 0

For my application I am using PSR-0 namespaces. Everything works beautiful!

Until I wanted to use Twig as template parser, Twig uses PEAR pseudo namespaces. Like Twig_Loader_Filesystem.

The problem is that when I want to use Twig inside my name-spaced application like this:

<?php
namespace Tact\ViewManager;

class ViewManager {

    public function init()
    {
        $loader = new Twig_Loader_Filesystem($this->templatepath);
        $this->twig = new Twig_Environment($loader);
    }  
}
?>

PHP will tell my autoloader to look for an class named Tact\ViewManager\Twig_Loader_Filesystem

How can I manage to autoload PEAR name-spaced style classes without the PSR-0 namespace of the invoking class?

My autoloader is able to load both PEAR and PSR-0..

Thanks in advance!

  • 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-11T04:55:25+00:00Added an answer on June 11, 2026 at 4:55 am

    This is because you are in the Tact\ViewManager namespace.
    The pseudo-namespaced classes are in fact in the global namespace,
    so you should prefix them with \ to call them:

    $loader = new \Twig_Loader_Filesystem($this->templatepath);
    

    If the \ prefix bugs you, you could do this:

    namespace Tact\ViewManager;
    
    use Twig_Loader_Filesystem;
    use Twig_Environment;
    
    class ViewManager {
        public function init()
        {
            $loader = new Twig_Loader_Filesystem($this->templatepath);
            $this->twig = new Twig_Environment($loader);
        }  
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've an application using MVC and Code First for persistence. Everything works fine in
Been developing an application using PHP's PEAR framework, but ran into an issue where
I develop an application using Struts, Spring, and Hibernate. My DAOs uses spring jdbc
I am developing an application using Symfony2. I am using Twig for templating an
I am creating an application using Grails Framework for which I plan to use
I create application using map. It works, but when there's no internet or wifi
I created a BlackBerry application using java-me and the BlackBerry specific API. It works
I just deployed an application using capistrano, nginx and unicorn. I used to use
I have a red5 application using java language and I use logback for logging.
I am developing iPhone application using SQLite . I decided to use fmdb .

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.