# I need help about PHP SCRIPT!

**URL:** <https://community.asterisk.org/t/i-need-help-about-php-script/26766>\
**Category:** Asterisk General\
**Created:** [April 28, 2009, 5:30pm UTC](https://community.asterisk.org/t/i-need-help-about-php-script/26766 "2009-04-28T17:30:30Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![heros](https://avatars.discourse-cdn.com/v4/letter/h/e8c25b/32.png) [@heros](https://community.asterisk.org/u/heros)\
**Post date:** [April 28, 2009, 5:30pm UTC](https://community.asterisk.org/t/i-need-help-about-php-script/26766/1 "2009-04-28T17:30:30Z")

</div>

here is my script:hello.php  
#!/usr/bin/php -q

\<?php require\_once('phpagi.php'); $agi=new $AGI(); $agi=answer(); $agi-\>exec('Playback','hello'); //hello is a gsm file in Sounds directory. $agi-\>verbose("hello done"); ?\>

here is my context:  
[test]  
exten=\>1,1,wait(1)  
exten=\>1,2,AGI(hello.php)  
exten=\>1,3,playback(vm-goodbye)  
exten=\>1,4,hangup()

after using SIP phone (X-litte) to call, Asterisk CLI display:

–launched AGI script /var/lib/asterisk/agi-bin/hello.php  
–\<SIP/truonglh-b7bbfca8\>AGI script hello.php completed, returning 0.  
But I don’t hear anything (my hello.gsm).I don’t know why! please help me!

Ah,if I replace exten=\>1,2,AGI(hello.php) by exten=\>1,2,AGI(agi-test.agi), everything work as expected! 😢 (agi-test.agi is already in agi-bin directory, and it is writen by perl,is it the reason???).

please help me!  
Thanks so much!

---

<div class="post-metadata">

**Author:** ![rk1](https://avatars.discourse-cdn.com/v4/letter/r/9f8e36/32.png) [@rk1](https://community.asterisk.org/u/rk1)\
**Post date:** [April 29, 2009, 9:40am UTC](https://community.asterisk.org/t/i-need-help-about-php-script/26766/2 "2009-04-29T09:40:39Z")

</div>

[quote=“heros”]  
[test]  
exten=\>1,1,wait(1)  
exten=\>1,2,AGI(hello.php)  
exten=\>1,3,playback(vm-goodbye)  
exten=\>1,4,hangup()  
please help me!  
Thanks so much![/quote]

hey hero…In the second line u should have that file hello.php in phpagi folder, So that it can use phpagi.php.  
like this  
exten=\>1,2,AGI(/phpagi-2.14/hello.php)

and u should have the hello sound file in /var/lib/asterisk/sounds.

Once try with it…u may solve ur problem…all d best

---

<div class="post-metadata">

**Author:** ![bira\_more](https://avatars.discourse-cdn.com/v4/letter/b/bbce88/32.png) [@bira\_more](https://community.asterisk.org/u/bira_more)\
**Post date:** [April 29, 2009, 1:57pm UTC](https://community.asterisk.org/t/i-need-help-about-php-script/26766/3 "2009-04-29T13:57:05Z")

</div>

go to directory of your file.  
Then from console type:  
./hello.php  
And see results.  
You can have different problems - file is not in /var/lib/asterisk/agi-bin/ directory./ Wrong permissions. Not installed all dependencies - I am using mainly perl, and cant say what exactly you have to install, but it is something like php-cli  
Of course - if permissions are wrong - you can start script from console, but Asterisk (which could run as different user) could have no permissions to run script.
