Skip to content

Instantly share code, notes, and snippets.

@shamun
Created June 3, 2011 17:12
Show Gist options
  • Save shamun/1006705 to your computer and use it in GitHub Desktop.
Save shamun/1006705 to your computer and use it in GitHub Desktop.
<?php
class TestController extends Zend_Controller_Action
{
public function unixAction()
{
$this->_helper->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender();
$test = new Application_Model_Myprocess();
//$test->start();
//Zend_Debug::dump($test->isRunning());
//while ($test->isRunning()) {sleep(1);}
echo 'All processes completed';
exit;
}
ERROR
===============
An error occurred
Can only run on CLI or CGI enviroment
#0 /var/www/html/pbx/application/controllers/TestController.php(15): ZendX_Console_Process_Unix->__construct()
#1 /var/www/html/pbx/library/Zend/Controller/Action.php(513): TestController->unixAction()
#2 /var/www/html/pbx/library/Zend/Controller/Dispatcher/Standard.php(295): Zend_Controller_Action->dispatch('unixAction')
#3 /var/www/html/pbx/library/Zend/Controller/Front.php(954): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http))
#4 /var/www/html/pbx/library/Zend/Application/Bootstrap/Bootstrap.php(97): Zend_Controller_Front->dispatch()
#5 /var/www/html/pbx/library/Zend/Application.php(366): Zend_Application_Bootstrap_Bootstrap->run()
#6 /var/www/html/pbx/public/index.php(26): Zend_Application->run()
#7 {main}
Test 1:
==========
[root@example php.d]# curl -v http://p/test/unix
* About to connect() to p port 80 (#0)
* Trying 127.0.0.1... connected
* Connected to p (127.0.0.1) port 80 (#0)
> GET /test/unix HTTP/1.1
> User-Agent: curl/7.21.3 (i386-redhat-linux-gnu) libcurl/7.21.3 NSS/3.12.9.0 zlib/1.2.5 libidn/1.19 libssh2/1.2.7
> Host: p
> Accept: */*
>
< HTTP/1.1 302 Found
< Date: Fri, 03 Jun 2011 17:15:55 GMT
< Server: Apache/2.2.17 (Fedora)
< X-Powered-By: PHP/5.3.6
< Set-Cookie: PHPSESSID=ccclda0f6ajaiudh6rj9375du3; path=/
< Expires: Thu, 19 Nov 1981 08:52:00 GMT
< Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
< Pragma: no-cache
< Location: /
< Content-Length: 0
< Connection: close
< Content-Type: text/html; charset=UTF-8
<
* Closing connection #0
[root@example php.d]#
Test 2:
==========
[root@example php.d]# php -m
[PHP Modules]
bz2
calendar
Core
ctype
curl
date
ereg
exif
fileinfo
filter
ftp
gd
gettext
gmp
hash
iconv
json
libxml
mbstring
mcrypt
mysql
mysqli
openssl
pcntl
pcre
PDO
pdo_mysql
pdo_sqlite
Phar
posix
readline
Reflection
session
shmop
SimpleXML
sockets
SPL
sqlite3
standard
sysvmsg
sysvsem
sysvshm
tokenizer
xml
zip
zlib
[Zend Modules]
Test 3:
==========
[root@example php.d]# php -r "var_dump(pcntl_fork() . '\n\r');"
string(8) "3366\n\r"
string(5) "0\n\r"
[root@example php.d]# php -r "var_dump(posix_kill() . '\n\r');"
PHP Warning: posix_kill() expects exactly 2 parameters, 0 given in Command line code on line 1
string(4) "\n\r"
[root@example php.d]#
OK OK
<?php
class Application_Model_Myprocess extends ZendX_Console_Process_Unix {
protected function _run() {
for ($i = 0; $i < 10; $i++) { sleep(1);}
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment