captcha, Image not show

hi yii’ers i want to ask about the captcha. why the captcha image is not visible. I’ve tried most of which exist in the forum but have not succeeded.

this my code


	<?php if(CCaptcha::checkRequirements()): ?>

	<div class="row">

		<?php echo $form->labelEx($model,'verifyCode'); ?>


		<?php $this->widget('CCaptcha'); ?>

		<?php echo $form->textField($model,'verifyCode'); ?>


		<div class="hint">Please enter the letters as they are shown in the image above.

		<br/>Letters are not case-sensitive.</div>


	<?php endif; ?>


	public function rules()


		return array(

			// name, email, subject and body are required

			array('name, email, subject, body', 'required'),

			// email has to be a valid email address

			array('email', 'email'),

			// verifyCode needs to be entered correctly

			array('verifyCode', 'captcha', 'allowEmpty'=>!CCaptcha::checkRequirements()),




public function actions()


		return array(

			// captcha action renders the CAPTCHA image displayed on the contact page






			// page action renders "static" pages stored under 'protected/views/site/pages'

			// They can be accessed via: index.php?r=site/page&view=FileName






please help from the Yii dev

If you don’t see a message “GD and FreeType PHP extensions are required” then your GD/FreeType support should be ok.

I would try to generate a completely new yii app and try the captcha on the contact page again.

If it works you have something wrong in your code, if not there is an other problem.

I’ve tried to change the view, models, and controllers related to the contact page with the code of the new applications that I created, but could not as well.

First of all you need to check the requirements -

Check the last line "GD extension with FreeType support" should say "passed"

GD extension with freetype support is passed

any solution ?

good you give the link…

check this link on your server -

it’s the contact page of the yii blog demo… here the captcha is shown… at least to me… check if you see the captcha code…

I can see it also in the link.

then I’ve tried to change the view, models and contoller on to that of the examples of these blogs, but the result is the same

the solution …

i guess …

or it may be because unwanted echo or white space in config/main.php or other files

Need to write also -

class MyController extends Controller


    public function accessRules() {

        return array('allow', 'actions' => array('captcha'), 'users' => array('*'));



I haven’t solved this myself, but noticed something that might help.

My CAPTCHA on contact page was working. but on the new captcha I was trying to create I noticed this in the image URL.


Using FireBug If I changed it too:


it would generate the CAPTCHA, so was not an issue with GD or anything.

Not sure if that helps.

UPDATE, the post above solved the problem for me.

You need to specify the action like this -

$this->widget('CCaptcha', array('captchaAction'=>'voucher/captcha'));

I had a captcha image not showing. It was because of this rule of the urlmanager:


which changing to this rule, solved the problem: