为什么绝对路径不能正确解析?

Why isn't the absolute path resolving correctly?

我正在尝试实现 Google 的新(呃)recaptcha 示例。我不是 Linux 路径方面的专家。

目录结构

PHP

<?php

// autoload.php @generated by Composer

require_once  '/vendor/composer/autoload_real.php';

return ComposerAutoloaderInit31f23b3d4150735cb5565ea0a0e8bdfe::getLoader();

?>

示例-captcha.php 文件

<?php

require_once 'autoload.php';


$siteKey === 'my-sitekey';
$secret = 'my-secret';

$lang = 'en';
?>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
        <title>reCAPTCHA Example</title>
        <link rel="shortcut icon" href="//www.gstatic.com/recaptcha/admin/favicon.ico" type="image/x-icon"/>
        <style type="text/css">
            body {
                margin: 1em 5em 0 5em;
                font-family: sans-serif;
            }
            fieldset {
                display: inline;
                padding: 1em;
            }
        </style>
    </head>
    <body>
        <h1>reCAPTCHA Example</h1>
        <?php   if ($siteKey === '' || $secret === ''): ?>
            <h2>Add your keys</h2>
            <p>If you do not have keys already then visit <tt>
            <a href = "https://www.google.com/recaptcha/admin">
                https://www.google.com/recaptcha/admin</a></tt> to generate them.
        Edit this file and set the respective keys in <tt>$siteKey</tt> and
        <tt>$secret</tt>. Reload the page after this.</p>
    <?php
elseif (isset($_POST['g-recaptcha-response'])):
    // The POST data here is unfiltered because this is an example.
    // In production, *always* sanitise and validate your input'
    ?>
    <h2><tt>POST</tt> data</h2>
    <tt><pre><?php var_export($_POST); ?></pre></tt>
    <?php

    $recaptcha = new \ReCaptcha\ReCaptcha($secret);

    $resp = $recaptcha->verify($_POST['g-recaptcha-response'], $_SERVER['REMOTE_ADDR']);

    if ($resp->isSuccess()):
// If the response is a success, that's it!
        ?>
        <h2>Success!</h2>
        <p>That's it. Everything is working. Go integrate this into your real project.</p>
        <p><a href="/">Try again</a></p>
        <?php
    else:
// If it's not successfull, then one or more error codes will be returned.
        ?>
        <h2>Something went wrong</h2>
        <p>The following error was returned: <?php
            foreach ($resp->getErrorCodes() as $code) {
                echo '<tt>' , $code , '</tt> ';
            }
            ?></p>
        <p>Check the error code reference at <tt><a href="https://developers.google.com/recaptcha/docs/verify#error-code-reference">https://developers.google.com/recaptcha/docs/verify#error-code-reference</a></tt>.
        <p><strong>Note:</strong> Error code <tt>missing-input-response</tt> may mean the user just didn't complete the reCAPTCHA.</p>
        <p><a href="/">Try again</a></p>
    <?php
    endif;
else:
// Add the g-recaptcha tag to the form you want to include the reCAPTCHA element
    ?>
    <p>Complete the reCAPTCHA then submit the form.</p>
    <form action="/" method="post">
        <fieldset>
            <legend>An example form</legend>
            <p>Example input A: <input type="text" name="ex-a" value="foo"></p>
            <p>Example input B: <input type="text" name="ex-b" value="bar"></p>

            <div class="g-recaptcha" data-sitekey="<?php echo $siteKey; ?>"></div>
            <script type="text/javascript"
                    src="https://www.google.com/recaptcha/api.js?hl=<?php echo $lang; ?>">
            </script>
            <p><input type="submit" value="Submit" /></p>
        </fieldset>
    </form>
<?php endif; ?>
</body>
</html>

error_log

我不明白这个引用是什么意思:(include_path='.:/opt/alt/php55/usr/share/pear:/opt/alt/php55/usr/share/php')

[05-May-2016 18:00:55 UTC] PHP Warning: 
require_once(/vendor/composer/autoload_real.php): failed to open
stream: No such file or directory in
/home/deje/public_html/writers-tryst/vendor/google/recaptcha/examples/autoload.php
on line 5 [05-May-2016 18:00:55 UTC] PHP Fatal error:  require_once():
Failed opening required '/vendor/composer/autoload_real.php'
include_path='.:/opt/alt/php55/usr/share/pear:/opt/alt/php55/usr/share/php')
in
/home/deje/public_html/writers-tryst/vendor/google/recaptcha/examples/autoload.php
on line 5

autoload.php 文件有误。将其更改为:

<?php

// autoload.php @generated by Composer

require_once  '/home/deje/public_html/writers-tryst/vendor/composer/autoload_real.php';

return ComposerAutoloaderInit31f23b3d4150735cb5565ea0a0e8bdfe::getLoader();

?>