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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T11:33:07+00:00 2026-06-01T11:33:07+00:00

I would like to know What is the best way to include 3rd party

  • 0

I would like to know What is the best way to include 3rd party php files in symfony2. I am using a different php – ajax package for uploading files in my symfony2 application. The package offers me some php oops code which i need to use in my symfony controller. I am creating objects of that code in my controller. So i would like to know where i can put that third party code or file and how can i include or create objects of that code in my symfony2 controller. Do we use require or include in symfony2 as well. If So is that the only approach.

  • 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-01T11:33:09+00:00Added an answer on June 1, 2026 at 11:33 am

    I’m not so sure about trying to add namespaces to a third party library. Twig, for example, does not use name spaces. And there really is no need. Consider for example a case where you want to use the PDF component from the Zend_Framework 1 library.

    In your app/autoload.php file you would do something like:

    $loader->registerPrefixes(array(
        'Twig_Extensions_' => $ws . 'Symfony/vendor/twig-extensions/lib',
        'Twig_'            => $ws . 'Symfony/vendor/twig/lib',
        'Zend_'            => $ws . 'ZendFramework-1.0.0/library',
    ));
    
    // And since Zend internally uses require/include we need to set an include path
    ini_set('include_path','.' .
    
        PATH_SEPARATOR . $ws . 'ZendFramework-1.0.0/library'
    
    );
    

    At this point we should be able to create 3rd part objects inside of controllers while letting the autoload system take care of finding and including the classes:

        $page = new \Zend_Pdf_Page(\Zend_Pdf_Page::SIZE_A4);
        $doc->pages[] = $page;
    
        $font1 = \Zend_Pdf_Font::fontWithName(\Zend_Pdf_Font::FONT_HELVETICA);
        $font2 = \Zend_Pdf_Font::fontWithName(\Zend_Pdf_Font::FONT_COURIER_BOLD);
    

    You do have to use the \ to get around the lack of namespacing.

    This answer does assume that your 3rd part library follows the more or less standard class naming convention. If it has it’s own auto loading functionality then just call it from autolaod.php as well. And if you don’t want to use autoloading at all then just set the include path and include away.

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

Sidebar

Related Questions

I would like to know what's the best way to organize my php project
I would like to know how to use Queue in the best functional way.
I would like to know what is the best, fastest and easiest way to
I am writing a Java applet, and would like to know the best way
I would like to know the best way to determine if the following code
I would like to know what are the best approaches for protecting apllication and
I would like to know what is the best import strategy within django reusable
I would like to know what is the best solution for storing large amount
Whats the best way to create my own template engine using php, to transfer
I'm creating a java open source utility package and I would like to know

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.