Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

can I suppress headers in PHP/CLI?

Posted on 2009-04-20
8
Medium Priority
?
1,018 Views
Last Modified: 2013-11-10
I have Zend Framework-based web site. When I start application from Cron I always get this output. How can I suppress such PHP headers in Zend? Or maybe it's a global PHP option?
X-Powered-By: PHP/5.2.9
Set-Cookie: PHPSESSID=a6f12eabbe240c78b7381418b4d21ce3; 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
Content-type: text/html

Open in new window

0
Comment
Question by:technoparkcorp
8 Comments
 
LVL 14

Expert Comment

by:shobinsun
ID: 24184836
Hi,

try with this:

expose_php = Off in php.ini file.
0
 
LVL 8

Expert Comment

by:aldanch
ID: 24185609

#!/usr/local/bin/php -q
 
<?
 
...
 
?>

Open in new window

0
 

Author Comment

by:technoparkcorp
ID: 24191875
I tried both options, no effect :(
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 3

Expert Comment

by:dazweeja
ID: 24193190
I think the -q option is what you need (as aldanch has written). Maybe the path is wrong for your installation?

Try this from a shell/command prompt:

php -q test.php
0
 

Author Comment

by:technoparkcorp
ID: 24193725
this is what I get when I use -q
<br />
<b>Fatal error</b>:  Uncaught exception 'Zend_Session_Exception' with message 'Session must be started before any output has been sent to the browser; output started in /0' in /home/xxx/library/Zend/Session.php:419
Stack trace:
#0 /home/xxx/application/bootstrap.php(92): Zend_Session::start()
#1 /home/xxx/application/Robot/run.php(22): require('/home/xxx...')
#2 {main}
  thrown in <b>/home/xxx/library/Zend/Session.php</b> on line <b>419</b><br />

Open in new window

0
 
LVL 3

Accepted Solution

by:
dazweeja earned 2000 total points
ID: 24194194
I think where getting to the problem now. If you look at this page, it says that Zend_Session is (was?) not supported in the CLI environment:

http://framework.zend.com/issues/browse/ZF-1720

So you can either run the script within a browser with your cron script (possible but a bit clunky) or maybe try putting this just before line 92 in bootstrap.php:

if (php_sapi_name() == 'cli') Zend_Session::$_unitTestEnabled = true;

Or some other code using the same check that will bypass Zend_Session if the script is run in the CLI environment.
0
 

Author Closing Comment

by:technoparkcorp
ID: 31572246
It's always "cli", in my case it's "cgi-fcgi". Anyway it works now, thanks!
0
 
LVL 3

Expert Comment

by:dazweeja
ID: 24203465
Thanks for the points. I assumed from your use of Zend_Session that this code must also be intended to be run in a browser.
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Suggested Courses
Course of the Month20 days, 23 hours left to enroll

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question