Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    New to the CF scene
    Join Date
    Apr 2012
    Posts
    7
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Failed opening required (include_path='.;c:\wamp\php\pear')

    Hello All,

    I have Wamp version 2.2 running php version 5.3.8.

    I downloaded PHPPowerPoint so that I can begin creating reports for a customer.

    The following line of code is giving me some trouble:

    Code:
    require_once('php_powerpoint/Classes/PHPPowerPoint.php');
    I get the following errors:

    Warning: require_once(Classes/PHPPowerPoint.php) [function.require-once]: failed to open stream: No such file or directory in C:\wamp\www\irma\php_powerpoint\Classes\PHPPowerpoint\Slide.php on line 30

    Fatal error: require_once() [function.require]: Failed opening required 'Classes/PHPPowerPoint.php' (include_path='.;c:\wamp\php\pear') in C:\wamp\www\irma\php_powerpoint\Classes\PHPPowerpoint\Slide.php on line 30

    I did some searching online and was coming across a lot of information about PEAR. However, I searched my wamp directories and I dont have any PEAR files (like go-pear.bat).

    Is PEAR really my problem? Or, is it something else? Thanks in advance for any help !

  • #2
    Senior Coder
    Join Date
    Apr 2010
    Posts
    1,419
    Thanks
    68
    Thanked 102 Times in 101 Posts
    The path to PHPPowerPoint.php isn't correct, it's saying the file is missing. So play around with the path to find the right one. That should clear it up.
    Been a sign maker for 7 years. My business:
    American Made Signs

  • #3
    New to the CF scene
    Join Date
    Apr 2012
    Posts
    7
    Thanks
    1
    Thanked 0 Times in 0 Posts
    The file I am trying to display is called powerpoint_report.php. It is located in my root project directory. The file I am trying to include in powerpoint_report.php is called PHPPowerPoint.php which is located in my *root*/php_powerpoint/Classes directory.

    So then, isn't the following code correct?

    Code:
    require_once('php_powerpoint/Classes/PHPPowerPoint.php');

  • #4
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    This has nothing to do with PEAR. This only represents the known path for PHP, which is the running directory, and the pear directory.
    The error doesn't match your include:Warning: require_once(Classes/PHPPowerPoint.php) [function.require-once]: failed to open stream: No such file or directory in C:\wamp\www\irma\php_powerpoint\Classes\PHPPowerpoint\Slide.php on line 30

    This indicates that you are calling a path under 'Classes/', not 'php_powerpoint/classes'. It is possible that it has it an __autoload or registered autoloader which has caused this.

    The inclusion path is the location of the running script. From the slide.php you can include using:
    PHP Code:
    require_once dirname(__FILE__) . '/../PHPPowerPoint.php'
    Which will fetch it from the directory above the Slide.php script.

  • #5
    New to the CF scene
    Join Date
    Apr 2012
    Posts
    7
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Thanks for the suggestion Fou-Lu.

    I tried replacing:

    Code:
    require_once 'Classes/PHPPowerPoint.php';
    with your code:

    Code:
    require_once dirname(__FILE__) . '/../PHPPowerPoint.php';
    And it worked for that particular include. However, I have approx. 15 other includes listed in the Slide.php file that will need the same type of modification. Instead of applying dirname(__FILE__) to each include, is there another way?

  • #6
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    No, if you are calling an inclusion with bad paths, you'll need to modify the paths to work either absolute (for which I don't recommend), absolute to server path (which will work except in a command line environment), or relative from file (which I recommend).

    The alternative is to register every possible path into the include_path. Can be done at a script level as well using a simple:
    PHP Code:
    set_include_path(get_include_path() . PATH_SEPARATOR dirname(__FILE__)); 
    But at this point you may as well just append the dirname(__FILE__) (or on newer versions of php __DIR__ will work).
    Using an inclusion path will be tricky since the files you want have partial paths which will make finding them a nightmare with an include path.

    Edit:
    However, if you are dealing explicitly with class objects, you can use the __autoload or even better an spl_register to add directories for the classes to look through. Works very well with namespaces in particular. This lets you automagically load classes when calling new, so inclusions are no longer required. Personally I still use an include off of the dir since I don't use auto_prepend_file to allow a global inclusion of a file designed to load specific classes.
    Last edited by Fou-Lu; 04-27-2012 at 07:01 PM.

  • #7
    New to the CF scene
    Join Date
    Apr 2012
    Posts
    7
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Thanks for all the help! I've got it working now


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •