We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

reCAPTCHA integration

I'm trying to integrate reCAPTCHA script into my app. But when I put code from (https://developers.google.com/recaptcha/docs/php)

require_once('recaptchalib.php');
$publickey = "here_is_my_public_key";
echo recaptcha_get_html($publickey);

into Volt template I got something like this:

Warning: require_once(/opt/lampp/htdocs/app/libraries/recaptchalib.php): failed to open stream: Permission denied in /opt/lampp/htdocs/app/cache/_opt_lampp_htdocs_app_views_session_index.volt.php on line 33

Fatal error: require_once(): Failed opening required '/opt/lampp/htdocs/app/cache/../libraries/recaptchalib.php' (include_path='.:/opt/lampp/lib/php') in /opt/lampp/htdocs/app/cache/_opt_lampp_htdocs_app_views_session_index.volt.php on line 33

bash sudo chmod 777 -R ./cache is also doesn't solve this problem, maybe somebody have such expirience?



98.9k

Does this directory (/opt/lampp/htdocs/app/libraries/recaptchalib.php) exists?

I saw at Phosphorum example on GitHub there are OAuth is used like a wrapper. So I'm implemented one wrapper for reCAPTCHA. I commit my handmade here: https://github.com/ttnaa/phalcon-recaptcha But it won't be called from main app. php Fatal error: Class 'Hakaba\Libraries\Recaptcha' not found in /opt/lampp/htdocs/app/controllers/SessionController.php on line 18 on this line I'm trying to create a new instance of this class:

use Hakaba\Libraries\Recaptcha;
....
$recaptcha = new Recaptcha();

in index.php i have:

'librariesDir'     => __DIR__ . '/../app/libraries/',
....
$loader->registerNamespaces(array(
        'Hakaba\Models' => $config->application->modelsDir,
        'Hakaba\Controllers' => $config->application->controllersDir,
        'Hakaba\Libraries' => $config->application->librariesDir
    ))->register();

Maybe I need to wrap this class in some specific way? I don't know why PHP can't find it. Can you look at it?

Chmod is also ok

[email protected]:/opt/lampp/htdocs/app$ ls -l
загалом 20
drwxrwxr-x 2 ttnaa ttnaa 4096 тра  8 19:36 cache
drwxrwxr-x 2 ttnaa ttnaa 4096 тра  9 01:58 controllers
drwxrwxr-x 2 ttnaa ttnaa 4096 тра  9 01:57 libraries
drwxrwxr-x 2 ttnaa ttnaa 4096 тра  8 19:39 models
drwxrwxr-x 8 ttnaa ttnaa 4096 тра  8 19:26 views

Very very very strange. But when I create a dummy class in same folder, error disappeared.

Hey guys! I updated repository, so you can use my class if you want ^_^

edited Jan '15

Hello everybody! I wish to propose my vision of recaptcha component (google recaptcha updated):

https://github.com/fizzka/phalcon-recaptcha