Ask your Symfony questions! Pay money and get answers fast! (more info)

Why am I see the code as text, instead of seeing the PHP rendered Symfony

See screenshot. This was working a few minutes ago. I was able to click a link and see a rendered form inside of our Fancybox overlay. And then something happened. I don't know what. It was between Subversion commits so I can not simply roll back to the previous version (or I could, but I'd lost a lot of work).

Any thoughts about why I am suddenly seeing text instead of the rendered code?

This is an admin auto-generated by the generator.

I did make a change to generated.yml, but I have since undone all changes and run "symfony cc" and I am still getting this problem.


UPDATE:

I do:

svn delete apps/frontend/modules/deal

and:

rm -rf cache/frontend/prod/modules/autoDeal

and:

symfony cc

and:

./symfony propel:generate-admin --theme="robotfruit" --module="deal" frontend Deal

and:

symfony cc

and yet the problem persists. I am still seeing the text that you can see in the screenshot. I am not seeing the output of rendered PHP code.

Assuming my co-worker did something that I did not know about, what might that be?


UPDATE:

This is an interesting clue.

If I point my browser at deal/index I see:

[?php require_once(dirname(__FILE__).'/../lib/BaseDealGeneratorConfiguration.class.php'); require_once(dirname(__FILE__).'/../lib/BaseDealGeneratorHelper.class.php'); /** * deal actions. * * @package ##PROJECT_NAME## * @subpackage deal * @author ##AUTHOR_NAME## */ abstract class autoDealActions extends sfActions { public function preExecute() { $this->configuration = new dealGeneratorConfiguration(); if (!$this->getUser()->hasCredential($this->configuration->getCredentials($this->getActionName()))) { $this->forward(sfConfig::get('sf_secure_module'), sfConfig::get('sf_secure_action')); } $this->dispatcher->notify(new sfEvent($this, 'admin.pre_execute', array('configuration' => $this->configuration))); $this->helper = new dealGeneratorHelper(); $this->modul = ModulPeer::retrieveByPk(0); $this->activateAppModul(); } public function executeIndex(sfWebRequest $request) { // filtering if ($request->getParameter('filters')) { $this->setFilters($request->getParameter('filters')); } // sorting if ($request->getParameter('sort')) { $this->setSort(array($request->getParameter('sort'), $request->getParameter('sort_type'))); } // pager if ($request->getParameter('page')) { $this->setPage($request->getParameter('page')); } $this->pager = $this->getPager(); $this->sort = $this->getSort(); } public function executeImport(sfWebRequest $request) { $c = new Criteria(); $c->add(DealPeer::FEED_TYPE_ID, 0); $this->Deals = DealPeer::doSelect($c); $this->form = $this->configuration->getForm(); $this->Deal = $this->form->getObject(); } public function activateAppModul() { $app_id = 1; $module_id = 0; if($app_module = AppModulPeer::retrieve($app_id, $module_id)) { } else { $module = ModulPeer::retrieveByPk($module_id); $app_module = new AppModul(); $app_module->setModulId($module_id); $app_module->setAppId($app_id); $app_module->setTitle($module->getName()); $app_module->save(); } $this->app_modul = $app_module; } public function executeFilter(sfWebRequest $request) { $this->setPage(1); if ($request->hasParameter('_reset')) { $this->setFilters($this->configuration->getFilterDefaults()); $this->redirect('@deal'); } $this->filters = $this->configuration->getFilterForm($this->getFilters());

If I go looking for:

grep -iR BaseDealGeneratorConfiguration *

I see:

apps/frontend/modules/deal/lib/dealGeneratorConfiguration.class.php
apps/admin/modules/deal/lib/dealGeneratorConfiguration.class.php
cache/frontend/prod/modules/autoDeal/lib/BaseDealGeneratorConfiguration.class.php


and if I:

cat cache/frontend/prod/modules/autoDeal/lib/BaseDealGeneratorConfiguration.class.php

I see:

<?php

/**
* deal module configuration.
*
* @package ##PROJECT_NAME##
* @subpackage deal
* @author ##AUTHOR_NAME##
* @version SVN: $Id: configuration.php 24171 2009-11-19 16:37:50Z Kris.Wallsmith $
*/
abstract class BaseDealGeneratorConfiguration extends sfModelGeneratorConfiguration
{
public function getNav()
{
return array();
}


Note that this file correctly starts off with "<?php" instead of "[?php".

The other auto-generated modules work fine, so this is something specific to the deals module.

Strangely, the deals module in the admin app is also having the same problem, though I have not touched the admin app, and I don't think my co-worker has either.

And this:

cat apps/frontend/modules/deal/lib/dealGeneratorConfiguration.class.php


Gives me:

<?php

/**
* deal module configuration.
*
* @package sf_sandbox
* @subpackage deal
* @author Your name here
* @version SVN: $Id: configuration.php 12474 2008-10-31 10:41:27Z fabien $
*/
class dealGeneratorConfiguration extends BaseDealGeneratorConfiguration
{
}


I can not find any file that starts off with "[?php" instead of "<?php".


Also:

This seems like a potentially serious bug in the security system of Symfony. Our "admin.php" app is locked down to those users who are admins. And if I go here:

admin.php

or here:

admin.php/feed

Then I am correctly asked to log in.

But if I go here:

admin.php/deal

Then I am not asked to log in. Instead I just get this garbage code dumped on the screen (I mean the plain text PHP code which you see above).

UPDATE:

In the end, it was this line in my form class, which I have now commented out:

public function updateObject($values = null)
{
$object = parent::updateObject($values);

$notification = new Notification();
$notification->setMessage($object->getDescription());
// default will be to notify at 40 hours before event starts
/*$notification->setPushAt(date('Y-m-d H:i:s', time() - 144000); */
$notification->setAppId($object->getAppId());

return $object;
}



Not sure why that caused a problem. I copy-and-pasted that block of code from another form class where it was working.

Answers (3)

2012-11-05

Luis Cordova answers:

oh no, did your server upgraded?

2012-11-05

Martin Palacio answers:

* Just in case, please post the contents of your generator.yml
* Check your server logs (/var/log/apache2/error.log or similar) and/or frontend_[dev|prod].log. It happens both in production and development environments?

This is the case when some partial in the admin gen module is generating bad php code. Please check also the generated files in cache/[dev|prod]/autoDeal for errors.


Lawrence Krubner comments:

this is the generator.yml:

generator:
class: sfPropelGenerator
param:
model_class: Deal
theme: robotfruit
non_verbose_templates: true
with_show: false
singular: Deal
plural: Deals
route_prefix: deal
with_propel_route: 1
actions_base_class: sfActions

config:
module_id: 7
nav:
index: { title: Deals }
new: { title: Add Deals }
actions: ~
fields: ~
list: ~
filter: ~
form:
class: DealForm
edit: ~
new: ~





Lawrence Krubner comments:

I thought the problem started when I added:

nav:
index: { title: Deals }
new: { title: Add Deals }


But then I removed that, re-ran the generation line:

./symfony propel:generate-admin --theme="robotfruit" --module="deal" frontend Deal

and :

symfony cc

and yet the problem persists.


Martin Palacio comments:

I insist in looking into your server/symfony logs. I bet you are missing some fatal error somewhere. Try to increase the PHP error level too.


Lawrence Krubner comments:

Possibly, but now there are so many other errors that this original problem gets drowned out. See my other question now posted.

As to the logs, if I do this:

tail --lines 40 /etc/httpd/logs/error_log-20121014


Then I get:

[Tue Nov 06 19:48:38 2012] [error] [client 67.247.7.85] PHP Warning: include(): Failed opening '/home/roboo/cache/frontend/prod/config/config_app.yml.php' for inclusion (include_path='.:/usr/share/pear:/usr/share/php') in /home/roboo/lib/vendor/symfony/lib/config/sfApplicationConfiguration.class.php on line 124
[Tue Nov 06 19:49:42 2012] [error] [client 67.247.7.85] PHP Warning: date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'UTC' for 'UTC/0.0/no DST' instead in /home/roboo/lib/vendor/symfony/lib/config/sfCompileConfigHandler.class.php on line 82
[Tue Nov 06 19:49:42 2012] [error] [client 67.247.7.85] PHP Warning: copy(/home/roboo/cache/frontend/prod/config/config_core_compile.yml.php): failed to open stream: Permission denied in /home/roboo/lib/vendor/symfony/lib/config/sfConfigCache.class.php on line 359
[Tue Nov 06 19:49:42 2012] [error] [client 67.247.7.85] PHP Warning: chmod(): No such file or directory in /home/roboo/lib/vendor/symfony/lib/config/sfConfigCache.class.php on line 365
[Tue Nov 06 19:49:42 2012] [error] [client 67.247.7.85] PHP Warning: include(/home/roboo/cache/frontend/prod/config/config_core_compile.yml.php): failed to open stream: No such file or directory in /home/roboo/lib/vendor/symfony/lib/config/sfConfigCache.class.php on line 263
[Tue Nov 06 19:49:42 2012] [error] [client 67.247.7.85] PHP Warning: include(): Failed opening '/home/roboo/cache/frontend/prod/config/config_core_compile.yml.php' for inclusion (include_path='.:/usr/share/pear:/usr/share/php') in /home/roboo/lib/vendor/symfony/lib/config/sfConfigCache.class.php on line 263
[Tue Nov 06 19:49:42 2012] [error] [client 67.247.7.85] PHP Warning: date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'UTC' for 'UTC/0.0/no DST' instead in /home/roboo/lib/vendor/symfony/lib/config/sfDefineEnvironmentConfigHandler.class.php on line 66
[Tue Nov 06 19:49:42 2012] [error] [client 67.247.7.85] PHP Warning: copy(/home/roboo/cache/frontend/prod/config/config_settings.yml.php): failed to open stream: Permission denied in /home/roboo/lib/vendor/symfony/lib/config/sfConfigCache.class.php on line 359
[Tue Nov 06 19:49:42 2012] [error] [client 67.247.7.85] PHP Warning: chmod(): No such file or directory in /home/roboo/lib/vendor/symfony/lib/config/sfConfigCache.class.php on line 365
[Tue Nov 06 19:49:42 2012] [error] [client 67.247.7.85] PHP Warning: include(/home/roboo/cache/frontend/prod/config/config_settings.yml.php): failed to open stream: No such file or directory in /home/roboo/lib/vendor/symfony/lib/config/sfApplicationConfiguration.class.php on line 121
[Tue Nov 06 19:49:42 2012] [error] [client 67.247.7.85] PHP Warning: include(): Failed opening '/home/roboo/cache/frontend/prod/config/config_settings.yml.php' for inclusion (include_path='.:/usr/share/pear:/usr/share/php') in /home/roboo/lib/vendor/symfony/lib/config/sfApplicationConfiguration.class.php on line 121
[Tue Nov 06 19:50:07 2012] [error] [client 67.247.7.85] PHP Warning: date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'UTC' for 'UTC/0.0/no DST' instead in /home/roboo/lib/vendor/symfony/lib/config/sfCompileConfigHandler.class.php on line 82
[Tue Nov 06 19:50:07 2012] [error] [client 67.247.7.85] PHP Warning: copy(/home/roboo/cache/frontend/prod/config/config_core_compile.yml.php): failed to open stream: Permission denied in /home/roboo/lib/vendor/symfony/lib/config/sfConfigCache.class.php on line 359
[Tue Nov 06 19:50:07 2012] [error] [client 67.247.7.85] PHP Warning: chmod(): No such file or directory in /home/roboo/lib/vendor/symfony/lib/config/sfConfigCache.class.php on line 365
[Tue Nov 06 19:50:07 2012] [error] [client 67.247.7.85] PHP Warning: include(/home/roboo/cache/frontend/prod/config/config_core_compile.yml.php): failed to open stream: No such file or directory in /home/roboo/lib/vendor/symfony/lib/config/sfConfigCache.class.php on line 263
[Tue Nov 06 19:50:07 2012] [error] [client 67.247.7.85] PHP Warning: include(): Failed opening '/home/roboo/cache/frontend/prod/config/config_core_compile.yml.php' for inclusion (include_path='.:/usr/share/pear:/usr/share/php') in /home/roboo/lib/vendor/symfony/lib/config/sfConfigCache.class.php on line 263
[Tue Nov 06 19:50:07 2012] [error] [client 67.247.7.85] PHP Fatal error: require(): Failed opening required '/home/roboo/cache/frontend/prod/config/config_factories.yml.php' (include_path='/home/roboo:/home/roboo/plugins/sfPropelORMPlugin/lib/vendor/phing:/home/roboo/plugins/sfPropelORMPlugin/lib/vendor/propel:/home/roboo/plugins/sfPropelORMPlugin/lib/vendor/phing/../:/home/roboo/plugins/sfPropelORMPlugin/lib/vendor/phing/classes:.:/usr/share/pear:/usr/share/php') in /home/roboo/lib/vendor/symfony/lib/util/sfContext.class.php on line 155
[Tue Nov 06 19:58:24 2012] [error] [client 67.247.7.85] PHP Warning: date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'UTC' for 'UTC/0.0/no DST' instead in /home/roboo/lib/vendor/symfony/lib/config/sfCompileConfigHandler.class.php on line 82
[Tue Nov 06 19:58:24 2012] [error] [client 67.247.7.85] PHP Warning: copy(/home/roboo/cache/frontend/prod/config/config_core_compile.yml.php): failed to open stream: Permission denied in /home/roboo/lib/vendor/symfony/lib/config/sfConfigCache.class.php on line 359
[Tue Nov 06 19:58:24 2012] [error] [client 67.247.7.85] PHP Warning: chmod(): No such file or directory in /home/roboo/lib/vendor/symfony/lib/config/sfConfigCache.class.php on line 365
[Tue Nov 06 19:58:24 2012] [error] [client 67.247.7.85] PHP Warning: include(/home/roboo/cache/frontend/prod/config/config_core_compile.yml.php): failed to open stream: No such file or directory in /home/roboo/lib/vendor/symfony/lib/config/sfConfigCache.class.php on line 263
[Tue Nov 06 19:58:24 2012] [error] [client 67.247.7.85] PHP Warning: include(): Failed opening '/home/roboo/cache/frontend/prod/config/config_core_compile.yml.php' for inclusion (include_path='.:/usr/share/pear:/usr/share/php') in /home/roboo/lib/vendor/symfony/lib/config/sfConfigCache.class.php on line 263
[Tue Nov 06 19:58:25 2012] [error] [client 67.247.7.85] Class sfPropelORMRouteCollection does not exist
[Tue Nov 06 19:59:06 2012] [error] [client 67.247.7.85] Class sfPropelORMRouteCollection does not exist
[Tue Nov 06 20:00:30 2012] [error] [client 66.249.74.168] File does not exist: /home/waleup/web/wp-content
[Tue Nov 06 20:01:06 2012] [error] [client 67.247.7.85] PHP Warning: date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'UTC' for 'UTC/0.0/no DST' instead in /home/roboo/lib/vendor/symfony/lib/config/sfRootConfigHandler.class.php on line 91
[Tue Nov 06 20:01:06 2012] [error] [client 67.247.7.85] PHP Warning: copy(/home/roboo/cache/frontend/prod/config/config_config_handlers.yml.php): failed to open stream: Permission denied in /home/roboo/lib/vendor/symfony/lib/config/sfConfigCache.class.php on line 359
[Tue Nov 06 20:01:06 2012] [error] [client 67.247.7.85] PHP Warning: chmod(): No such file or directory in /home/roboo/lib/vendor/symfony/lib/config/sfConfigCache.class.php on line 365
[Tue Nov 06 20:01:06 2012] [error] [client 67.247.7.85] PHP Warning: require(/home/roboo/cache/frontend/prod/config/config_config_handlers.yml.php): failed to open stream: No such file or directory in /home/roboo/lib/vendor/symfony/lib/config/sfConfigCache.class.php on line 279
[Tue Nov 06 20:01:06 2012] [error] [client 67.247.7.85] PHP Fatal error: require(): Failed opening required '/home/roboo/cache/frontend/prod/config/config_config_handlers.yml.php' (include_path='.:/usr/share/pear:/usr/share/php') in /home/roboo/lib/vendor/symfony/lib/config/sfConfigCache.class.php on line 279
[Tue Nov 06 20:01:08 2012] [error] [client 67.247.7.85] PHP Warning: date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'UTC' for 'UTC/0.0/no DST' instead in /home/roboo/lib/vendor/symfony/lib/config/sfRootConfigHandler.class.php on line 91
[Tue Nov 06 20:01:08 2012] [error] [client 67.247.7.85] PHP Warning: copy(/home/roboo/cache/frontend/prod/config/config_config_handlers.yml.php): failed to open stream: Permission denied in /home/roboo/lib/vendor/symfony/lib/config/sfConfigCache.class.php on line 359
[Tue Nov 06 20:01:08 2012] [error] [client 67.247.7.85] PHP Warning: chmod(): No such file or directory in /home/roboo/lib/vendor/symfony/lib/config/sfConfigCache.class.php on line 365
[Tue Nov 06 20:01:08 2012] [error] [client 67.247.7.85] PHP Warning: require(/home/roboo/cache/frontend/prod/config/config_config_handlers.yml.php): failed to open stream: No such file or directory in /home/roboo/lib/vendor/symfony/lib/config/sfConfigCache.class.php on line 279
[Tue Nov 06 20:01:08 2012] [error] [client 67.247.7.85] PHP Fatal error: require(): Failed opening required '/home/roboo/cache/frontend/prod/config/config_config_handlers.yml.php' (include_path='.:/usr/share/pear:/usr/share/php') in /home/roboo/lib/vendor/symfony/lib/config/sfConfigCache.class.php on line 279
[Tue Nov 06 20:02:11 2012] [error] [client 198.59.50.99] Empty module and/or action after parsing the URL "/favicon.ico" (/)., referer: http://virtualspa.mrsteam.com/
[Tue Nov 06 20:02:47 2012] [error] [client 67.247.7.85] PHP Fatal error: require(): Failed opening required '/home/roboo/cache/frontend/prod/config/modules_homepage_config_security.yml.php' (include_path='/home/roboo:/home/roboo/plugins/sfPropelORMPlugin/lib/vendor/phing:/home/roboo/plugins/sfPropelORMPlugin/lib/vendor/propel:/home/roboo/plugins/sfPropelORMPlugin/lib/vendor/phing/../:/home/roboo/plugins/sfPropelORMPlugin/lib/vendor/phing/classes:.:/usr/share/pear:/usr/share/php') in /home/roboo/cache/frontend/prod/config/config_core_compile.yml.php on line 265
[Tue Nov 06 20:14:08 2012] [error] [client 66.249.74.168] File does not exist: /home/waleup/web/wp
[Tue Nov 06 20:30:11 2012] [error] [client 174.64.181.111] Empty module and/or action after parsing the URL "/favicon.ico" (/).
[Tue Nov 06 20:30:33 2012] [error] [client 174.64.181.111] Empty module and/or action after parsing the URL "/favicon.ico" (/).


Lawrence Krubner comments:

I just noticed this:

failed to open stream: Permission denied in /home/roboo/lib/vendor/symfony/lib/config/sfConfigCache.class.php


ls -al shows read permissions for everyone, so I don't see how permission could be denied, but the file was owned by root, so just to be safe I did "chown -R apache *" to be sure Apache/PHP had ownership of everything in the project.

Now I can see the site again, though the problem I describe in the above question is still a problem: I see PHP code as plain text, instead of seeing its rendered output.

And, relevant to another question I asked, I am afraid to run "symfony cc" since that seems to erase files in the cache folder that Symfony needs and is unable to re-create.

2012-11-07

lordkain answers:

Hi, this problem usually happens when the log and cache directory are not writable, the directory must have 777 and also the content inside, perhaps you can serve is to delete the files you have in the directories log, cache and then apply 777 to these folders.

Also if you have access to ssh can run

./symfony project: permissions

if any of you use symfony 1.x

I hope you serve something my comment.