Using Windows 10 with Wampstack-5.6.28-1 which has composer.phar already loaded, at the command prompt I entered
C:\Bitnami\Wampstack-5.6.28-1\php>composer require gregwar/captcha. This then created .json and .lock files and a ..\php\vendor
folder. I copied the vendor folder into \apache2\htdocs and added index.php as follows (which is mostly copied from the gregwar usage
sheet)

<?php
require 'vendor\autoload.php';
use gregwar\Captcha\CaptchaBuilder;
$builder = new CaptchaBuilder;
$builder->build;
header('content-type: image/jpeg');
$builder->output;
?>

Then http://localhost/index.php ought (I thought) to show me some captchas. But it doesn't. It gives a blank sheet. No errors
are indicated. What have I done wrongly, please ?

    Sorry - there is a typo in the above. What I've got is :

    <?php
    require_once "vendor\autoload.php";
    use gregwar\Captcha\CaptchaBuilder;
    $builder = new CaptchaBuilder;
    $builder->build();
    header('Content-type: image/jpeg');
    $builder->output();
    ?>

    but it still doesn't ....

      A few things to help debug:

      When you get the blank screen, is there anything "interesting" if you use your browser's "view source" feature?

      Is there anything in your php error log? (You may need to do some poking around and/or Googling to find out where wampstack puts it.)

      Alternatively, changing your php.ini file to turn on "display_errors" will output those error messages right to the browser. Or, if it's not a plain old syntax error somewhere in the code, you can stick this at the top of the file being called:

      <?php
      ini_set('display_errors', true); // set to false in production
      error_reporting(E_ALL);
      

      My initial suspicion is that something in that installation process specified an absolute file path that now is failing when you moved the files...but that's purely a guess for now.

        Thank you for this. The index.php now looks like

        <?php
        ini_set('display_errors',true);
        error_reporting(E_ALL);
        require_once "vendor\autoload.php";
        echo "Hello World"; // This works
        use gregwar\Captcha\CaptchaBuilder;
        $builder = new CaptchaBuilder;
        $builder->build();
        header('Content-type: image/jpeg');
        $builder->output(); // This is producing a jpeg
        ?>

        and when run it gives :

        Hello World
        Fatal error: Class 'gregwar\Captcha\CaptchaBuilder' not
        found in C:\Bitnami\wampstack-5.6.28-1\apache2\htdocs\index.php on line 7

        Originally I went to the command prompt and wrote C:\Bitnami...\php>composer require gregwar/captcha. This then made the .hson and .loch file and created a folder
        vendor under \php. I copied \vendor to...\ apache2\htdocs together with the index.php given above.

        Additionally to the above, I am wondering whether a facilty called gd is activated in the wampstack. It seems that I need this but I haven't figured out whether it is active or not

          I have put this to one side for now. I have obviously made some gross error because the package does not work as stated and I have not been able to trick it into action. It does not recognise a Class, although I can see that the class CaptchaBuilder exists inside CaptchaBuilder. php which is itself in folder Captcha. I bet I've got an instruction wrong, but still.... the documentation seems insufficient for anyone but a Master of the Universe.

            Write a Reply...