 |
Account Login
|
 |
 |
Latest Articles
|
 |
 |
IRC Channel
|
 |
 |
Associates
|
 |
 |
Associates
|
 |
|
 |
|
 |
|
 |
03-20-2009, 05:36 PM
|
#1 (permalink)
|
|
The Prestige
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
|
Zend Framework
Ye, I'm having some troubles with Zend framework.
More specificly the view files.
I have this:
index.phtml
Code:
<h1 align="center">
Hello, Zend Framework MVC!
</h1>
<?php echo 'Testing'; ?>
It outputs "Hello, Zend Framework MVC", but not the "Testing" part.
I tried other stuff, but it's almost like the PHP won't evaluate or be proccessed by the server.
I'm using WAMP on localhost btw.
When I check the source code on the page, I even see the PHP code there, but with the php tags and the echo part aswell. Like an HTML comment.. or something.
Any clues?
Also, another problem I'm having is when creating the .htaccess file. Whenever I have an access file, it gives me 500 server error, no matter what's in the file. Do I have to enable mod_rewrite or anything? Why is it giving me that error?
Thanks!
__________________
|
|
|
|
03-20-2009, 06:20 PM
|
#2 (permalink)
|
|
The Gregarious
Join Date: Feb 2009
Location: New York
Posts: 645
Thanks: 64
|
Quote:
Originally Posted by Tanax
Ye, I'm having some troubles with Zend framework.
More specificly the view files.
I have this:
index.phtml
Code:
<h1 align="center">
Hello, Zend Framework MVC!
</h1>
<?php echo 'Testing'; ?>
It outputs "Hello, Zend Framework MVC", but not the "Testing" part.
I tried other stuff, but it's almost like the PHP won't evaluate or be proccessed by the server.
I'm using WAMP on localhost btw.
When I check the source code on the page, I even see the PHP code there, but with the php tags and the echo part aswell. Like an HTML comment.. or something.
Any clues?
Also, another problem I'm having is when creating the .htaccess file. Whenever I have an access file, it gives me 500 server error, no matter what's in the file. Do I have to enable mod_rewrite or anything? Why is it giving me that error?
Thanks!
|
Ok, your issue is that your webserver, I assume IIS? Is not interpreting your code as PHP. That's why the PHP tags are being printed out.
Perhaps it doesn't know about .phtml?
Try renaming your file to: index.php
And see what happens...
|
|
|
|
03-20-2009, 06:29 PM
|
#3 (permalink)
|
|
The Prestige
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
|
Quote:
Originally Posted by allworknoplay
Ok, your issue is that your webserver, I assume IIS? Is not interpreting your code as PHP. That's why the PHP tags are being printed out.
Perhaps it doesn't know about .phtml?
Try renaming your file to: index.php
And see what happens...
|
IIS? No I'm using WAMP.
And yea, I guess, but how to solve that?
PHP tags aren't actually printed on the page, only visible in the sourcecode of the page.
I don't know, it should work :S
I can't rename it to .php, because then Zend won't recognize it so it won't work..
__________________
|
|
|
|
03-20-2009, 06:46 PM
|
#4 (permalink)
|
|
The Gregarious
Join Date: Feb 2009
Location: New York
Posts: 645
Thanks: 64
|
Quote:
Originally Posted by Tanax
IIS? No I'm using WAMP.
And yea, I guess, but how to solve that?
PHP tags aren't actually printed on the page, only visible in the sourcecode of the page.
I don't know, it should work :S
I can't rename it to .php, because then Zend won't recognize it so it won't work..
|
oh my bad....everytime I think windows, I think IIS...
Ok, so in your apache config called: httpd.conf
You need to add this:
AddType application/x-httpd-php .php
AddType application/x-httpd-php .phtml
so do a search for "AddType application" and you should find the area to add it.
then restart your apache...
|
|
|
|
03-20-2009, 07:36 PM
|
#5 (permalink)
|
|
The Prestige
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
|
Quote:
Originally Posted by allworknoplay
oh my bad....everytime I think windows, I think IIS...
Ok, so in your apache config called: httpd.conf
You need to add this:
AddType application/x-httpd-php .php
AddType application/x-httpd-php .phtml
so do a search for "AddType application" and you should find the area to add it.
then restart your apache...
|
Hehe, it's okay!
Thanks for that.
I edited this file:
C:\wamp\bin\apache\apache2.2.8\conf
and added the phtml extension.
This was already there:
Code:
AddType application/x-httpd-php .php
AddType application/x-httpd-php .php3
so I just added this below:
Code:
AddType application/x-httpd-php .phtml
and then restarted.
However, the problem still persists :S 
I still can't use PHP in the .phtml files.
Although, I solved the rewrite issue, cause I read your post in the other Zend thread about having to enable it in apache, and I found it, and enabled it, so that part works now!
Only the .phtml issue left to solve 
__________________
|
|
|
|
03-20-2009, 07:37 PM
|
#6 (permalink)
|
|
The Gregarious
Join Date: Feb 2009
Location: New York
Posts: 645
Thanks: 64
|
Quote:
Originally Posted by Tanax
Although, I solved the rewrite issue, cause I read your post in the other Zend thread about having to enable it in apache, and I found it, and enabled it, so that part works now!
Only the .phtml issue left to solve 
|
Ok can you copy and paste your code exactly so I can take a look?
|
|
|
|
03-20-2009, 07:43 PM
|
#7 (permalink)
|
|
The Prestige
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
|
I'm using the exact copy-paste from quick guide except I added a variable to the view object.
IndexController.php
php Code:
<?php // application/controllers/IndexController.php
/** * IndexController is the default controller for this application * * Notice that we do not have to require 'Zend/Controller/Action.php', this * is because our application is using "autoloading" in the bootstrap. * * @see [url]http://framework.zend.com/manual/en/zend.loader.html#zend.loader.load.autoload[/url] */ class IndexController extends Zend_Controller_Action { /** * The "index" action is the default action for all controllers. This * will be the landing page of your application. * * Assuming the default route and default router, this action is dispatched * via the following urls: * / * /index/ * /index/index * * @return void */ public function indexAction() { $this->view->text = 'Hi'; } }
index.phtml
php Code:
<h1 align="center"> Hello, Zend Framework MVC! </h1>
<?= $this->text ?>
And I've also tried it without the shorttags, thinking that was the problem, but didn't work with regular php echo style either..
__________________
|
|
|
|
03-20-2009, 07:48 PM
|
#9 (permalink)
|
|
The Gregarious
Join Date: Feb 2009
Location: New York
Posts: 645
Thanks: 64
|
Quote:
Originally Posted by Tanax
index.phtml
php Code:
<h1 align="center"> Hello, Zend Framework MVC! </h1>
<?= $this->text ?>
And I've also tried it without the shorttags, thinking that was the problem, but didn't work with regular php echo style either..
|
Ok, I was just going to say, it could be the short tags.
I know that PHP6 is discontinuing the short tags, I'm not sure if PHP5 supports it or not....
Anyways, can you create a simple test file and see if the PHP works?
Create a file called: test.php
And in it just type this:
Code:
<?php
$test = 'test';
echo $test;
?>
Let me know what you get...what we want to do is forget about the Zend framework. We need to see if Apache itself is configured correctly for PHP..
|
|
|
|
03-20-2009, 07:51 PM
|
#10 (permalink)
|
|
The Prestige
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
|
Yes yes, the PHP works great outside of the .phtml file. Otherwise the index bootstrap wouldn't really work, now would it?
PHP5 supports shorttags.
Check out the screenshots in my previous post for visual of the error.
__________________
|
|
|
|
03-20-2009, 07:59 PM
|
#11 (permalink)
|
|
The Gregarious
Join Date: Feb 2009
Location: New York
Posts: 645
Thanks: 64
|
Quote:
Originally Posted by Tanax
Yes yes, the PHP works great outside of the .phtml file. Otherwise the index bootstrap wouldn't really work, now would it?
PHP5 supports shorttags.
Check out the screenshots in my previous post for visual of the error.
|
Hmm ok, let me get my framework configured and see how mine turns out. I'm working on something else right now so give me about 2 hours and I'll get back to you!!!
|
|
|
|
03-20-2009, 11:36 PM
|
#12 (permalink)
|
|
The Gregarious
Join Date: Feb 2009
Location: New York
Posts: 645
Thanks: 64
|
How is your htaccess configured? Because you're in windows it might be a problem.
I am having issues right now getting mine to work, so I have to backtrack and thoroughly read the instructions...
|
|
|
|
03-20-2009, 11:47 PM
|
#13 (permalink)
|
|
The Prestige
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
|
It looks like the one in the quick start guide.
Code:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ /index.php [NC,L]
The rewrite works great though. I can access controllers and their respectivly functions by changing the url to localhost/controllername/functionname and it works great.
It's just the part with the viewfiles that does get processed by PHP(or something - I don't know, I'm just guessing that, since the PHP tags and code gets put on the page like a HTML comment - again, see the screenshots).
Ah, we'll figure it out, hehe 
__________________
|
|
|
|
03-20-2009, 11:55 PM
|
#14 (permalink)
|
|
The Gregarious
Join Date: Feb 2009
Location: New York
Posts: 645
Thanks: 64
|
Quote:
Originally Posted by Tanax
It looks like the one in the quick start guide.
Code:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ /index.php [NC,L]
The rewrite works great though. I can access controllers and their respectivly functions by changing the url to localhost/controllername/functionname and it works great.
It's just the part with the viewfiles that does get processed by PHP(or something - I don't know, I'm just guessing that, since the PHP tags and code gets put on the page like a HTML comment - again, see the screenshots).
Ah, we'll figure it out, hehe 
|
Take a look at your apache config and see where it looks for .htaccess.
See, in linux, it's called .htaccess. But with Windows you might have to call it htaccess.txt and then tell your config to look for that instead of the default .htaccess.
Also check your log files and see what the error_log says....
|
|
|
|
03-20-2009, 11:59 PM
|
#15 (permalink)
|
|
The Prestige
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
|
Quote:
Originally Posted by allworknoplay
Take a look at your apache config and see where it looks for .htaccess.
See, in linux, it's called .htaccess. But with Windows you might have to call it htaccess.txt and then tell your config to look for that instead of the default .htaccess.
Also check your log files and see what the error_log says....
|
But as I said, the .htaccess file has nothing to do with this as it is working perfectly well and is doing everything it is supposed to do..
And yes, in Windows we call it .htaccess aswell as you do in LINUX.
I checked it, it didn't have any error log about this  
__________________
|
|
|
|
03-21-2009, 12:07 AM
|
#16 (permalink)
|
|
The Gregarious
Join Date: Feb 2009
Location: New York
Posts: 645
Thanks: 64
|
Quote:
Originally Posted by Tanax
But as I said, the .htaccess file has nothing to do with this as it is working perfectly well and is doing everything it is supposed to do..
And yes, in Windows we call it .htaccess aswell as you do in LINUX.
I checked it, it didn't have any error log about this  
|
Ok, well I am currently recompiling my apache because mod_rewrite isn't working for me right now.
Once I can get my own test bed to work, I'll see what we can do about yours! 
|
|
|
|
03-21-2009, 07:31 AM
|
#17 (permalink)
|
|
The Frequenter
Join Date: Dec 2007
Location: Bucharest, Romania
Posts: 438
Thanks: 3
|
Find this line:
Code:
short_open_tag = Off
in your php.ini file, and change it to "On", then restart apache. That should do it.
PS: it was not required that you added the .phtml extension to the .htaccess file as the views (templates) are internally parsed by Zend (the template contents are evaluated by PHP, not directly accessed via the web browser). Also, you should use:
PHP Code:
<?php echo 'stuff'; ?>
instead of the short form, so that you will not have problems when going live with the project. If it's a test project it's ok, but you might get very angry if the server you're going to move the project to doesn't have short_open_tag on (and that is quite usual).
__________________
I have optimistic thoughts, even though sometimes (if not always) life's a bitch.
|
|
|
|
03-21-2009, 11:32 AM
|
#18 (permalink)
|
|
The Prestige
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
|
Quote:
Originally Posted by xenon
Find this line:
Code:
short_open_tag = Off
in your php.ini file, and change it to "On", then restart apache. That should do it.
PS: it was not required that you added the .phtml extension to the .htaccess file as the views (templates) are internally parsed by Zend (the template contents are evaluated by PHP, not directly accessed via the web browser). Also, you should use:
PHP Code:
<?php echo 'stuff'; ?>
instead of the short form, so that you will not have problems when going live with the project. If it's a test project it's ok, but you might get very angry if the server you're going to move the project to doesn't have short_open_tag on (and that is quite usual).
|
Ye, I found that line before and set it to On and restarted the Apache. However, the problem still persists.
I didn't add .phtml extension to .htaccess. I added it to httpd.conf in apache folder.
And yes, I tried it with regular PHP tags, but that didn't work either..  
__________________
|
|
|
|
03-21-2009, 01:14 PM
|
#19 (permalink)
|
|
The Frequenter
Join Date: Dec 2007
Location: Bucharest, Romania
Posts: 438
Thanks: 3
|
Is the PHP extension even loaded in Apache? You must have a line in your httpd.conf file that says something like this:
Code:
LoadModule php5_module "c:/webserver/bin/php/php5.2.9-1/php5apache2_2.dll"
This is what I have on my Windows box, running WAMP server. PHP will not work if it's not "injected" into the Apache engine first. If it is, then something must be wrong with that dll file (probably corrupt). Check the Apache error log if the line above is present (and, obviously, uncommented) in your httpd.conf file.
PS: I was referring to the httpd.conf file in the post before.
__________________
I have optimistic thoughts, even though sometimes (if not always) life's a bitch.
|
|
|
|
03-21-2009, 03:48 PM
|
#20 (permalink)
|
|
The Prestige
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
|
Quote:
Originally Posted by xenon
Is the PHP extension even loaded in Apache? You must have a line in your httpd.conf file that says something like this:
Code:
LoadModule php5_module "c:/webserver/bin/php/php5.2.9-1/php5apache2_2.dll"
This is what I have on my Windows box, running WAMP server. PHP will not work if it's not "injected" into the Apache engine first. If it is, then something must be wrong with that dll file (probably corrupt). Check the Apache error log if the line above is present (and, obviously, uncommented) in your httpd.conf file.
PS: I was referring to the httpd.conf file in the post before.
|
I think so..
I found this line in httpd.conf
Code:
LoadModule php5_module "c:/wamp/bin/php/php5.2.6/php5apache2_2.dll"
And the thing is, I don't think that there's something wrong with that, because PHP files works great with PHP. I have numerous other projects on this localhost server(that aren't using Zend Framework) and they work perfectly well.
Also, if PHP didn't work, how come the index file redirects every request to the correct controller?
Ah I see! My bad then 
__________________
|
|
|
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|