Search code examples
phprequire-once

Question about including files with require_once


I have downloaded this API.

If you go to lib/Paypal/Profile/Handler/Array.php you will find this line:

require_once 'PayPal.php';

Since the PayPal.php file is in the lib/ folder, I expected something like this:

require_once '../../../../PayPal.php'

So...where is set what is the "root" folder of the API?

NOTE: my question has a reason: I'm trying to know why I'm getting an error like this:

Warning: require_once(PayPal.php): failed to open stream: No such file or directory in /home/me/app1/plugins/mbpPlatformFrontendPlugin/lib/paypal/PayPal/Profile/Handler/Array.php on line 9

Regards

Javi


Solution

  • When you run the built-in installer (/install.php), it adds code to set the include_path here:

    install.php[130-135]
    
    $code = "<?php\n" .
        "//*******************************************\n" .
        "// AUTO-GENERATED include for PayPal PHP SDK\n" .
        "// Created by install.php on $stamp\n" .
        "//*******************************************\n\n" .
        "set_include_path('$sdk_dir' . DIRECTORY_SEPARATOR . '" . $libdir . "' . PATH_SEPARATOR . get_include_path());\n";
    

    Which is why the README.html file tells you to run the included installer in order to use the samples.