PHP AGI script is giving fatal error: Class 'AGI' not found

I have installed asterisk 1.6.2.22 and I have created the php script to call from the dialplan.

testAgi.php script :

[quote] #!/usr/local/bin/php -q

<?php set_time_limit(0); require('phpagi.php'); $agi = new AGI(); $agi->answer(); // Play the tt-monkeys file from /var/lib/asterisk/sounds $agi->stream_file('tt-monkeys'); $agi->hangup(); ?>[/quote]

And the extension.conf :

[quote]exten => 6565,1,Answer
exten => 6565,2,AGI(testAgi.php)
exten => 6565,3,Hangup[/quote]

It gives the following error

[quote] #!/usr/local/bin/php -q
PHP Warning: include(phpagi.php): failed to open stream: No such file or directory in /var/lib/asterisk/agi-bin/testAgi.php on line 5
PHP Warning: include(): Failed opening ‘phpagi.php’ for inclusion (include_path=’.:/usr/share/pear:/usr/share/php’) in /var/lib/asterisk/agi-bin/testAgi.php on line 5
PHP Fatal error: Class ‘AGI’ not found in /var/lib/asterisk/agi-bin/testAgi.php on line 7[/quote]

Please give me some suggestion.

Thank you very much.

-Urmi

This is the primary error:

[quote=“urmi.l”][quote]PHP Warning: include(): Failed opening ‘phpagi.php’ for inclusion (include_path=’.:/usr/share/pear:/usr/share/php’) in /var/lib/asterisk/agi-bin/testAgi.php on line 5
[/quote][/quote]

Make sure that phpagi.php is installed and that it is in a directory which is in php’s include path.

Thank you for the quick reply.

I have tried installing phpagi-2.20. But its not getting install. Can you please tell me how to install it ?

-Urmi

Hello Urmi;

can you check the permission of files, i mean give the files full read write execute permission

hope this will help

Yes, I have already given the full permission to the .php file. still its not working.

Any other clue ?

Thank you very much for your reply.

-Urmi

also make sure that the file phpagi.php is there in the right directory with the full permissions

Thanks

I think they have already said that phpagi failed to install.

I would hope the installer would have said why it failed to install.

Its working now. :smile:

Download phpagi 2.x files from phpagi.sourceforge.net/
Installed the phpagi-2.20/ and put the source in /home/sources directory.
Then I have added the following line in my .php file

[quote]ini_set( “include_path”, “/home/sources/” );
include(‘phpagi.php’);
$agi = new AGI();
[/quote]

Thank you for the help.