Go Back   SitePoint Forums > Forum Index > Program Your Site > PHP
Newsletter FAQ Members List Calendar Mark Forums Read

New to SitePoint Forums? Register here for free!

SitePoint Sponsor
 
Reply
 
Thread Tools Display Modes
Old Nov 10, 2006, 10:28   #1
KnightsPrayer
SitePoint Member
 
Join Date: Oct 2006
Posts: 24
Question Setting up CakePhp

I was looking at an article about how one can achieve a good structured PHP MySql website with CakePhp. So I started to see what CakePhp was all about. I followed the instructions the article suggested to use, however I am unable to make the header appear. I get an error message that states:

Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at c:\webs\test\cake\app\config\database.php:75) in c:\webs\test\cake\cake\libs\session.php on line 132

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at c:\webs\test\cake\app\config\database.php:75) in c:\webs\test\cake\cake\libs\session.php on line 132

Warning: Cannot modify header information - headers already sent by (output started at c:\webs\test\cake\app\config\database.php:75) in c:\webs\test\cake\cake\libs\session.php on line 133

However, I have the statements: Your database configuration file is present.
Cake is able to connect to the database. The css file seems to work except for the background, and images.

My configuration is WAMP Apache 2.2.3, PHP Version 5.1.6, MySql 5.0.22, with the document root set to "C:/webs/test/" Where I then put Cake in the test folder. I have this as the directory: <Directory "C:/webs/test"> made sure that this was changed from none to all: AllowOverride All and uncommented LoadModule rewrite_module modules/mod_rewrite.so and yet I still have problems with this configuration. Is there something that I am missing? .thtml is a file type but I am unsure how to make it a file type. I don't know if this is my problem but I am sure that it may be.

I am new at this program, as you can tell, and yet I am hopeful that I can use it to see if this will be a good place to make the scripts in PHP more secure and allow for a good markup. Could someone please help me on this? Apache 2.2.3 is a lot different from it's predecessor and I had to work out a great deal of problems with it's initial setup. If anyone could help me with this I would be greatful.

Thanks,

KnightsPrayer
KnightsPrayer is offline   Reply With Quote
Old Nov 10, 2006, 10:57   #2
Kailash Badu
SitePoint Mentor
bronze trophy
 
Kailash Badu's Avatar
 
Join Date: Nov 2005
Posts: 2,505
You have fouled up the code by sending heading information after out has been send. Actually, for a quick fix you can do away with this by adding ob_start() at the top of the page. But because CakePHP is a MVC framework it could be confusing to decide where to put that line of code. I used CakePHP a few months ago and i followed exact instructions at http://www.sitepoint.com/article/app...opment-cakephp and it had worked like a charm for me. So would you mind going through the article.

Apache 2.2.3 is problematic with PHP 5.0.x or 5.1.x . You need 5.2 for that to work which is not officially out as of now. However, may be WAMP fixes it up in someway else the script wouldn't work in the first place. Nonetheless, this thread could be useful.
Kailash Badu is offline   Reply With Quote
Old Nov 10, 2006, 11:08   #3
Kailash Badu
SitePoint Mentor
bronze trophy
 
Kailash Badu's Avatar
 
Join Date: Nov 2005
Posts: 2,505
Quote:
You need 5.2 for that to work which is not officially out as of now
Actually, PHP 5.2 just got out 8 days ago.
Kailash Badu is offline   Reply With Quote
Old Nov 10, 2006, 16:19   #4
clamcrusher
SitePoint Wizard
silver trophy
 
Join Date: Mar 2006
Posts: 6,132
you cannot send output before sending headers. session_start() sends headers.
php has told you where the output was sent, including which file, and which line.
c:\webs\test\cake\app\config\database.php:75

to me it sounds like you modified the file to produce some output.
output can be defined as text, html, or even whitespace characters. so yes, a space or blank new line is "output". it doesnt matter if the output comes from inside <?php ?> or not. its still output.

fix your problem on line 75.
clamcrusher is offline   Reply With Quote
Old Nov 10, 2006, 16:38   #5
KnightsPrayer
SitePoint Member
 
Join Date: Oct 2006
Posts: 24
Quote:
Originally Posted by Kailash Badu
Actually, PHP 5.2 just got out 8 days ago.
Thanks for the update on this but..., if you look at the Tanguay tutorial you do not need to load the dll in the httpd.conf file if you configure the file correctly. I have been using this configuration and I have not had a problem with using php 5.1.6. I think it is due to the htaccess or something like possibly the mod_rewrite not being properly used. It executes the php code fine, I am probably not configuring the access to the webroot of the CakePhp. As a matter of fact I have not told Apache where the webroot is, I have just put the application in the folder where my Document Root is pointing. I don't know if this matters or not, but when executing PHP Info script I see that 5.1.6 is working along with MySql 5.0.22. PhpMyadmin (newest stable realease) is working properly, so I don't know what the problem is. I am intending to go ahead and install the newest version of PHP as I try to keep up with all of the newest stable versions, but I don't think this will solve my problem.
Here was the solution that worked with my installation. If you look in the comments you will see a comment by Snaps11 on how to deal with a work around so that Apache executes the .dll you are talking about without having to put it in the httpd.conf file. http://www.tanguay.info/wamp/installPhp5.php5

My configuration works for everything that I have tried on it. There is just something about the htaccess file that wont work. I did read the sitepoint colum that discusses this topic, that is why I decided to try and install it. Seems promising.

What did you think of it? Do you still use it or did you find it limiting or something else. Would really like to know. Inquiring minds

Anything else it could be would be helpful. Thanks for your attention to my question.

KnightsPrayer
KnightsPrayer is offline   Reply With Quote
Old Nov 10, 2006, 16:44   #6
KnightsPrayer
SitePoint Member
 
Join Date: Oct 2006
Posts: 24
Quote:
Originally Posted by clamcrusher
you cannot send output before sending headers. session_start() sends headers.
php has told you where the output was sent, including which file, and which line.
c:\webs\test\cake\app\config\database.php:75

to me it sounds like you modified the file to produce some output.
output can be defined as text, html, or even whitespace characters. so yes, a space or blank new line is "output". it doesnt matter if the output comes from inside <?php ?> or not. its still output.

fix your problem on line 75.
Hmm, sounds like a solution. Glad you notice this. This was the only file that I touched in CakePhp, so it is probably the best place to start. Thanks for the tip.
KnightsPrayer is offline   Reply With Quote
Old Nov 10, 2006, 16:56   #7
KnightsPrayer
SitePoint Member
 
Join Date: Oct 2006
Posts: 24
Quote:
Originally Posted by clamcrusher
you cannot send output before sending headers. session_start() sends headers.
php has told you where the output was sent, including which file, and which line.
c:\webs\test\cake\app\config\database.php:75

to me it sounds like you modified the file to produce some output.
output can be defined as text, html, or even whitespace characters. so yes, a space or blank new line is "output". it doesnt matter if the output comes from inside <?php ?> or not. its still output.

fix your problem on line 75.
That was the problem.
KnightsPrayer is offline   Reply With Quote
Old Nov 10, 2006, 17:18   #8
KnightsPrayer
SitePoint Member
 
Join Date: Oct 2006
Posts: 24
Question Cake Php Header not show as in sitepoint article.

Does anyone know why I only get This as the header for CakePhp:

CakePHP Rapid Development

Your database configuration file is present.

Cake is able to connect to the database
and why I do not get the Icon for CakePhp? Along with the background color. Is this something that I am supposed to define myself? When I look at the source of the document I see that the Icon is called but for some reason it is not executed. This is what I see at the top of the document and then it calls for the css file after this which does execute fine along with the Div. <title>CakePHP : Home</title>
<link rel="icon" href="/cake/favicon.ico" type="image/x-icon" />
<link rel="shortcut icon" href="/cake/favicon.ico" type="image/x-icon" />
Just curious if I am installing this correctly or not. When I look at the sitepoint column listed above, I see the CakePhp logo, yet I do not see it on the page that I get when I have installed it. Any help would be appreciated.

KnightsPrayer
KnightsPrayer is offline   Reply With Quote
Old Nov 10, 2006, 18:38   #9
markl999
Sell crazy someplace else
 
markl999's Avatar
 
Join Date: Aug 2003
Location: Manchester, UK
Posts: 4,038
What you are seeing is correct. Maybe previous versions produced the output that Sitepoint shows but the latest version(s) show what you are seeing.
markl999 is offline   Reply With Quote
Old Nov 11, 2006, 08:43   #10
superuser2
SitePoint Guru
 
superuser2's Avatar
 
Join Date: Aug 2006
Posts: 601
I have recently configured cake myself, and yes, that's what it should show you. I would suggest reading the manual (cakephp.org) and click manual.
superuser2 is offline   Reply With Quote
Old Nov 11, 2006, 09:36   #11
KDesigns
Are You There?
 
KDesigns's Avatar
 
Join Date: Oct 2003
Location: Your Monitor
Posts: 1,155
You guys are right... Didn't do enough reading up.

Thanks!
KDesigns is offline   Reply With Quote
Old Nov 11, 2006, 13:01   #12
KnightsPrayer
SitePoint Member
 
Join Date: Oct 2006
Posts: 24
Thumbs up Thanks for the help

Quote:
Originally Posted by markl999
What you are seeing is correct. Maybe previous versions produced the output that Sitepoint shows but the latest version(s) show what you are seeing.
Thank you for letting me know this. I was not sure. This will make it a lot easier to continue.

KnightsPrayer
KnightsPrayer is offline   Reply With Quote
Old Nov 11, 2006, 13:03   #13
KnightsPrayer
SitePoint Member
 
Join Date: Oct 2006
Posts: 24
Quote:
Originally Posted by superuser2
I have recently configured cake myself, and yes, that's what it should show you. I would suggest reading the manual (cakephp.org) and click manual.
I have read parts of the manual and so now I will continue reading the rest of it. Thanks for your attention to this matter.

KnightsPrayer
KnightsPrayer is offline   Reply With Quote
Old Nov 11, 2006, 13:06   #14
KnightsPrayer
SitePoint Member
 
Join Date: Oct 2006
Posts: 24
Thumbs up Thanks for clarifying

Quote:
Originally Posted by superuser2
I have recently configured cake myself, and yes, that's what it should show you. I would suggest reading the manual (cakephp.org) and click manual.
Thank you for also clarifying this. I can now go on into the rest of the install.
KnightsPrayer is offline   Reply With Quote
Old Nov 11, 2006, 14:35   #15
superuser2
SitePoint Guru
 
superuser2's Avatar
 
Join Date: Aug 2006
Posts: 601
I hope you enjoy cakePHP, it takes some experience to get used to it, but once you get the hang of it it's quite nice. I, personally, used to be concerned about weather or not my app would work. Now I am actually concerned about usability and design. It really makes mysql simpler so you can focus on making the best program you can.

Happy coding!
superuser2 is offline   Reply With Quote
Old Nov 11, 2006, 16:01   #16
KnightsPrayer
SitePoint Member
 
Join Date: Oct 2006
Posts: 24
Question .thtml extension and where to put it in httpd.conf

Quote:
Originally Posted by superuser2
I hope you enjoy cakePHP, it takes some experience to get used to it, but once you get the hang of it it's quite nice. I, personally, used to be concerned about weather or not my app would work. Now I am actually concerned about usability and design. It really makes mysql simpler so you can focus on making the best program you can.

Happy coding!
Thanks again. Just a question though, how did you handle the .thtml in the httpd.con file, or does one need to address this? I was looking at the manual and it tells me to address this in the httpd.conf file as a file type. Looking at my file types it just addresses this as #Tanguay Tutorial??? Not sure if this works for Apache 2.22 for cake extension filetype

ScriptAlias /php/ "c:/php/"
AddType application/x-httpd-php .php .php5 .thtml
Action application/x-httpd-php "/php/php-cgi.exe"
SetEnv PHPRC "C:/php"

or do I use an AddType application/cake .thtml
Or do I not need to address this because I have the following in the httpd.conf DefaultType text/plain or do I add it to the ???????????
I don't even know if I need to use if if I have the DefaultType as explained above. Could you elaborate if you Know???
KnightsPrayer is offline   Reply With Quote
Old Nov 11, 2006, 16:39   #17
markl999
Sell crazy someplace else
 
markl999's Avatar
 
Join Date: Aug 2003
Location: Manchester, UK
Posts: 4,038
You don't need to worry about the .thtml extension as you never access those files directly in the browser using cakePHP (/foo/bar for example, never /foo/bar/whatever.thtml). The only place you might want to address it is with your editor, making the .thtml files highlight as .html would be.
markl999 is offline   Reply With Quote
Old Nov 11, 2006, 17:08   #18
KDesigns
Are You There?
 
KDesigns's Avatar
 
Join Date: Oct 2003
Location: Your Monitor
Posts: 1,155
Questions.... How come when I access Cake at http://localhost/caketest I get a 400 Bad Request Error, but when I access it at http://localhost/caketest/ it loads fine?
KDesigns is offline   Reply With Quote
Old Nov 11, 2006, 17:15   #19
markl999
Sell crazy someplace else
 
markl999's Avatar
 
Join Date: Aug 2003
Location: Manchester, UK
Posts: 4,038
Quote:
Originally Posted by KDesigns
Questions.... How come when I access Cake at http://localhost/caketest I get a 400 Bad Request Error, but when I access it at http://localhost/caketest/ it loads fine?
See if this helps
markl999 is offline   Reply With Quote
Old Nov 11, 2006, 17:22   #20
KDesigns
Are You There?
 
KDesigns's Avatar
 
Join Date: Oct 2003
Location: Your Monitor
Posts: 1,155
Sure does! Thanks!
KDesigns is offline   Reply With Quote
Old Nov 11, 2006, 21:01   #21
KnightsPrayer
SitePoint Member
 
Join Date: Oct 2006
Posts: 24
Thumbs up Thanks for the reply

Quote:
Originally Posted by markl999
You don't need to worry about the .thtml extension as you never access those files directly in the browser using cakePHP (/foo/bar for example, never /foo/bar/whatever.thtml). The only place you might want to address it is with your editor, making the .thtml files highlight as .html would be.
Thank you for your input. I really appreciate it.

KnightsPrayer
KnightsPrayer is offline   Reply With Quote
Old Nov 11, 2006, 21:44   #22
markl999
Sell crazy someplace else
 
markl999's Avatar
 
Join Date: Aug 2003
Location: Manchester, UK
Posts: 4,038
Quote:
Originally Posted by KnightsPrayer
Thank you for your input. I really appreciate it.
And your politeness throughout this thread is appreciated too. Thanks.
markl999 is offline   Reply With Quote
Old Nov 12, 2006, 16:10   #23
superuser2
SitePoint Guru
 
superuser2's Avatar
 
Join Date: Aug 2006
Posts: 601
Thanks markl999, I was having that problem too.
superuser2 is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread | Next Thread »

Thread Tools
Display Modes

 
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Sponsored Links
 
Forum Jump


All times are GMT -7. The time now is 18:56.


Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Copyright 1998-2009, SitePoint Pty Ltd. All Rights Reserved