This forum is in READ-ONLY mode.
You can look around, but if you want to ask a new question, please use Stack Overflow.

Newbie - Day 2: 500 Internal Server error after click Create

Discussion around this tutorial for symfony 1.0.x

Newbie - Day 2: 500 Internal Server error after click Create

by binro01 » Sun Aug 03, 2008 10:57 pm

Hi all,

Almost finished with day 2, and I have been able to generate the CRUD files and navigate to http://virthost/question URL, but when I click the Create link (http://symfony/question/create) I get a 500 Internal server error...

Not much other info on the error was given to me.

I did do a symfony cc to to attempt to clear the cache.

Any help to fully test my CRUD scaffold would be much appreciated

I'm running Symfony on top of my WAMP v2.0 stack

Thanks in advance

Rob

some more info:

when I navigate to http://symfony/frontend_dev.php/question/create I get the following error:

[RuntimeException]
Class "User" must implement a "__toString" method to be rendered in a "sfWidgetFormPropelSelect" widget
stack trace

* at ()
in SF_SYMFONY_LIB_DIR\plugins\sfPropelPlugin\lib\propel\widget\ sfWidgetFormPropelSelect.class.php line 89 ...
86.
87. if (!method_exists($this->getOption('model'), $method))
88. {
89. throw new RuntimeException(sprintf('Class "%s" must implement a "%s" method to be rendered in a "%s" widget', $this->getOption('model'), $method, __CLASS__));
90. }
91.
92. foreach ($objects as $object)
* at sfWidgetFormPropelSelect->getChoices()
in n/a line n/a ...
* at call_user_func_array(array(object('sfWidgetFormPropelSelect' ), 'getChoices'), array())
in SF_SYMFONY_LIB_DIR\util\sfCallable.class.php line 62 ...
59.
60. $arguments = func_get_args();
61.
62. return call_user_func_array($this->callable, $arguments);
63. }
64. }
65.
* at sfCallable->call()
in SF_SYMFONY_LIB_DIR\widget\sfWidgetFormSelect.class.php line 65 ...
62. $choices = $this->getOption('choices');
63. if ($choices instanceof sfCallable)
64. {
65. $choices = $choices->call();
66. }
67.
68. return $this->renderContentTag('select', " ".implode(" ", $this->getOptionsForSelect($value, $choices))." ", array_merge(array('name' => $name), $attributes));
* at sfWidgetFormSelect->render('question[user_id]', null, array(), null)
in SF_SYMFONY_LIB_DIR\form\sfFormField.class.php line 117 ...
114. */
115. function render($attributes = array())
116. {
117. return $this->widget->render($this->parent ? $this->parent->getWidget()->generateName($this->name) : $this->name, $this->value, $attributes, $this->error);
118. }
119.
120. /**
* at sfFormField->render()
in SF_SYMFONY_LIB_DIR\form\sfFormField.class.php line 58 ...
55. {
56. try
57. {
58. return $this->render();
59. }
60. catch (Exception $e)
61. {
* at sfFormField->__toString()
in SF_ROOT_DIR\apps\frontend\modules\question\templates\editSuc cess.php line 23 ...
20. <th><label for="question_user_id">User id</label></th>
21. <td>
22. <?php echo $form['user_id']->renderError() ?>
23. <?php echo $form['user_id'] ?>
24. </td>
25. </tr>
26. <tr>
* at require('C:\wamp\www\SymfonyProject\apps\frontend\modules\qu estion\templates\editSuccess.php')
in SF_SYMFONY_LIB_DIR\view\sfPHPView.class.php line 77 ...
74. // render
75. ob_start();
76. ob_implicit_flush(0);
77. require($_sfFile);
78.
79. return ob_get_clean();
80. }
* at sfPHPView-> renderFile('C:\wamp\www\SymfonyProject\apps\frontend\modules /question/templates/editSuccess.php')
in SF_SYMFONY_LIB_DIR\view\sfPHPView.class.php line 174 ...
171. $this->attributeHolder->set('sf_type', 'action');
172.
173. // render template file
174. $content = $this->renderFile($this->getDirectory().'/'.$this->getTemplate());
175.
176. if (sfConfig::get('sf_cache') && !is_null($uri))
177. {
* at sfPHPView->render()
in SF_SYMFONY_LIB_DIR\filter\sfExecutionFilter.class.php line 153 ...
150. break;
151.
152. case sfView::RENDER_CLIENT:
153. $viewData = $view->render();
154. $this->context->getResponse()->setContent($viewData);
155. break;
156.
* at sfExecutionFilter->executeView('question', 'create', 'Success', array(object('QuestionForm')))
in SF_SYMFONY_LIB_DIR\filter\sfExecutionFilter.class.php line 114 ...
111. return;
112. }
113.
114. $this->executeView($actionInstance->getModuleName(), $actionInstance->getActionName(), $viewName, $actionInstance->getVarHolder()->getAll());
115. }
116.
117. /**
* at sfExecutionFilter->handleView(object('sfFilterChain'), object('questionActions'), 'Success')
in SF_SYMFONY_LIB_DIR\filter\sfExecutionFilter.class.php line 47 ...
44. $timer->addTime();
45. $timer = sfTimerManager::getTimer(sprintf('View "%s" for "%s/%s"', $viewName, $actionInstance->getModuleName(), $actionInstance->getActionName()));
46.
47. $this->handleView($filterChain, $actionInstance, $viewName);
48.
49. $timer->addTime();
50. }
* at sfExecutionFilter->execute(object('sfFilterChain'))
in SF_SYMFONY_LIB_DIR\filter\sfFilterChain.class.php line 53 ...
50. }
51.
52. // execute the next filter
53. $this->chain[$this->index]->execute($this);
54. }
55. }
56.
* at sfFilterChain->execute()
in SF_SYMFONY_LIB_DIR\filter\sfCommonFilter.class.php line 29 ...
26. public function execute($filterChain)
27. {
28. // execute next filter
29. $filterChain->execute();
30.
31. // execute this filter only once
32. $response = $this->context->getResponse();
* at sfCommonFilter->execute(object('sfFilterChain'))
in SF_SYMFONY_LIB_DIR\filter\sfFilterChain.class.php line 53 ...
50. }
51.
52. // execute the next filter
53. $this->chain[$this->index]->execute($this);
54. }
55. }
56.
* at sfFilterChain->execute()
in SF_SYMFONY_LIB_DIR\filter\sfRenderingFilter.class.php line 33 ...
30. public function execute($filterChain)
31. {
32. // execute next filter
33. $filterChain->execute();
34.
35. if (sfConfig::get('sf_logging_enabled'))
36. {
* at sfRenderingFilter->execute(object('sfFilterChain'))
in SF_SYMFONY_LIB_DIR\filter\sfFilterChain.class.php line 53 ...
50. }
51.
52. // execute the next filter
53. $this->chain[$this->index]->execute($this);
54. }
55. }
56.
* at sfFilterChain->execute()
in SF_SYMFONY_LIB_DIR\controller\sfController.class.php line 250 ...
247. }
248.
249. // process the filter chain
250. $filterChain->execute();
251. }
252. else
253. {
* at sfController->forward('question', 'create')
in SF_SYMFONY_LIB_DIR\controller\sfFrontWebController.class.php line 53 ...
50. }
51.
52. // make the first request
53. $this->forward($moduleName, $actionName);
54. }
55. catch (sfException $e)
56. {
* at sfFrontWebController->dispatch()
in SF_SYMFONY_LIB_DIR\util\sfContext.class.php line 164 ...
161. */
162. public function dispatch()
163. {
164. $this->getController()->dispatch();
165. }
166.
167. /**
* at sfContext->dispatch()
in SF_ROOT_DIR\web\frontend_dev.php line 12 ...
9. require_once(dirname(__FILE__).'/../config/ProjectConfigurat ion.class.php');
10.
11. $configuration = ProjectConfiguration::getApplicationConfiguration('frontend' , 'dev', true);
12. sfContext::createInstance($configuration)->dispatch();
13.

symfony settings ...

mod_question_enabled: true
mod_question_is_internal: false
mod_question_view_class: sfPHP
sf_admin_web_dir: /sf/sf_admin
sf_app: frontend
sf_app_base_cache_dir: 'C:\wamp\www\SymfonyProject\cache\frontend'
sf_app_cache_dir: 'C:\wamp\www\SymfonyProject\cache\frontend\dev'
sf_app_config_dir: 'C:\wamp\www\SymfonyProject\apps\frontend\config'
sf_app_dir: 'C:\wamp\www\SymfonyProject\apps\frontend'
sf_app_i18n_dir: 'C:\wamp\www\SymfonyProject\apps\frontend\i18n'
sf_app_lib_dir: 'C:\wamp\www\SymfonyProject\apps\frontend\lib'
sf_app_module_dir: 'C:\wamp\www\SymfonyProject\apps\frontend\modules'
sf_app_template_dir: 'C:\wamp\www\SymfonyProject\apps\frontend\templates'
sf_apps_dir: 'C:\wamp\www\SymfonyProject\apps'
sf_cache: false
sf_cache_dir: 'C:\wamp\www\SymfonyProject\cache'
sf_calendar_web_dir: /sf/calendar
sf_charset: utf-8
sf_check_lock: false
sf_check_symfony_version: false
sf_compat_10: false
sf_compressed: false
sf_config_cache_dir: 'C:\wamp\www\SymfonyProject\cache\frontend\dev\config'
sf_config_dir: 'C:\wamp\www\SymfonyProject\config'
sf_csrf_secret: false
sf_data_dir: 'C:\wamp\www\SymfonyProject\data'
sf_debug: true
sf_default_culture: en
sf_doc_dir: 'C:\wamp\www\SymfonyProject\doc'
sf_enabled_modules:
- default
sf_environment: dev
sf_error_404_action: error404
sf_error_404_module: default
sf_error_reporting: 8191
sf_escaping_method: ESC_SPECIALCHARS
sf_escaping_strategy: false
sf_etag: false
sf_i18n: false
sf_i18n_cache_dir: 'C:\wamp\www\SymfonyProject\cache\frontend\dev\i18n'
sf_lib_dir: 'C:\wamp\www\SymfonyProject\lib'
sf_log_dir: 'C:\wamp\www\SymfonyProject\log'
sf_logging_enabled: true
sf_login_action: login
sf_login_module: default
sf_max_forwards: 5
sf_module_cache_dir: 'C:\wamp\www\SymfonyProject\cache\frontend\dev\modules'
sf_module_disabled_action: disabled
sf_module_disabled_module: default
sf_no_script_name: false
sf_orm: propel
sf_path_info_array: SERVER
sf_path_info_key: PATH_INFO
sf_plugins_dir: 'C:\wamp\www\SymfonyProject\plugins'
sf_prototype_web_dir: /sf/prototype
sf_relative_url_root: null
sf_rich_text_js_dir: js/tiny_mce
sf_root_dir: 'C:\wamp\www\SymfonyProject'
sf_secure_action: secure
sf_secure_module: default
sf_standard_helpers:
- Partial
- Cache
- Form
sf_strip_comments: true
sf_symfony_lib_dir: 'C:\wamp\bin\php\php5.2.5\PEAR\symfony'
sf_template_cache_dir: 'C:\wamp\www\SymfonyProject\cache\frontend\dev\template'
sf_test_cache_dir: 'C:\wamp\www\SymfonyProject\cache\frontend\dev\test'
sf_test_dir: 'C:\wamp\www\SymfonyProject\test'
sf_timer_start: 1217816153.0388
sf_upload_dir: 'C:\wamp\www\SymfonyProject\web\uploads'
sf_url_format: PATH
sf_use_database: true
sf_validation_error_class: form_error
sf_validation_error_id_prefix: error_for_
sf_validation_error_prefix: ' ↓ '
sf_validation_error_suffix: ' ↓'
sf_web_debug: true
sf_web_debug_web_dir: /sf/sf_web_debug
sf_web_dir: 'C:\wamp\www\SymfonyProject\web'
symfony.asset.javascripts_included: false
symfony.asset.stylesheets_included: false
symfony.view.question_create_template: edit

request ...

parameterHolder:
action: create
module: question
attributeHolder:
formats: { txt: text/plain, js: [application/javascript, application/x-javascript, text/javascript], css: text/css, json: [application/json, application/x-json], xml: [text/xml, application/xml, application/x-xml], rdf: application/rdf+xml, atom: application/atom+xml }

response ...

options:
logging: '1'
charset: utf-8
content_type: 'text/html; charset=utf-8'
cookies: { }
httpHeaders:
Content-Type: 'text/html; charset=utf-8'
javascripts:
first: { }
'': { }
last: { }
stylesheets:
first: { }
'': { main: { } }
last: { }
metas:
robots: 'index, follow'
httpMetas:
Content-Type: 'text/html; charset=utf-8'

user ...

options:
auto_shutdown: false
culture: null
default_culture: en
use_flash: true
logging: '1'
timeout: 1800
attributeHolder: { }
culture: en

global vars ...

cookie:
symfony: pnr2nlae4minmgboc394e5spr7
env: { }
files: { }
get: { }
post: { }
server:
COMSPEC: 'C:\windows\system32\cmd.exe'
DOCUMENT_ROOT: 'C:/wamp/www/SymfonyProject/web'
GATEWAY_INTERFACE: CGI/1.1
HTTP_ACCEPT: 'text/xml,application/xml,application/xhtml+xml,text/html;q= 0.9,text/plain;q=0.8,image/png,*/*;q=0.5'
HTTP_ACCEPT_CHARSET: 'ISO-8859-1,utf-8;q=0.7,*;q=0.7'
HTTP_ACCEPT_ENCODING: 'gzip,deflate'
HTTP_ACCEPT_LANGUAGE: 'en-us,en;q=0.5'
HTTP_CONNECTION: keep-alive
HTTP_COOKIE: symfony=pnr2nlae4minmgboc394e5spr7
HTTP_HOST: symfony
HTTP_KEEP_ALIVE: '300'
HTTP_USER_AGENT: 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.16) Gecko/20080702 Firefox/2.0.0.16'
PATH: 'c: uby\bin;C:\windows\system32;C:\windows;C:\windows\Syste m32\Wbem;C:\Program Files\ATI Technologies\ATI Control Panel'
PATHEXT: .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.RB;.RBW
PATH_INFO: /question/create
PATH_TRANSLATED: 'redirect:\index.php\create'
PHP_SELF: /frontend_dev.php/question/create
QUERY_STRING: ''
REMOTE_ADDR: 127.0.0.1
REMOTE_PORT: '4365'
REQUEST_METHOD: GET
REQUEST_TIME: 1217816153
REQUEST_URI: /frontend_dev.php/question/create
SCRIPT_FILENAME: 'C:/wamp/www/SymfonyProject/web/frontend_dev.php'
SCRIPT_NAME: /frontend_dev.php
SERVER_ADDR: 127.0.0.1
SERVER_ADMIN: [url=mailto:admin@localhost]admin@localhost[/url]
SERVER_NAME: symfony
SERVER_PORT: '80'
SERVER_PROTOCOL: HTTP/1.1
SERVER_SIGNATURE: ''
SERVER_SOFTWARE: 'Apache/2.2.8 (Win32) PHP/5.2.5'
SystemRoot: 'C:\windows'
WINDIR: 'C:\windows'
session:
symfony/user/sfUser/attributes: { }
symfony/user/sfUser/authenticated: false
symfony/user/sfUser/credentials: { }
symfony/user/sfUser/culture: en
symfony/user/sfUser/lastRequest: 1217816043

symfony v.1.1.1 - php 5.2.5
for help resolving this issue, please visit http://www.symfony-project.org/.
binro01
Junior Member
 
Posts: 1
Joined: Sun Aug 03, 2008 10:51 pm
Location: Long Island, NY

Re: Newbie - Day 2: 500 Internal Server error after click Create

by halfer » Thu Aug 07, 2008 12:03 pm

You are running symfony 1.1.x, but Askeet only (presently) works in 1.0 - sorry! There has been some discussion that this should have been updated for 1.1, but as ever with open source projects, it's a matter of how much time people have to donate to the project.

If you are happy to learn 1.0, Askeet is a good way to go. However if you want to learn 1.1 (I've not really done anything with it, but the Forms stuff looks excellent) then you would be better off with other tutorials. The material at thatsquality.com would be a good start, or do a web search.
halfer
Faithful Member
 
Posts: 10148
Joined: Mon Jan 30, 2006 1:16 pm
Location: West Midlands, UK

Re: Newbie - Day 2: 500 Internal Server error after click Create

by cloud » Thu Sep 04, 2008 4:49 pm

Well I went to the http://www.thatsquality.com/ but it seems that even that guy is having trouble to keep up with it. so any suggestions where one could learn 1.1 version
cloud
Junior Member
 
Posts: 8
Joined: Sun Aug 31, 2008 5:52 pm

Re: Newbie - Day 2: 500 Internal Server error after click Create

by halfer » Thu Sep 04, 2008 5:00 pm

The stuff there is still very relevant, it's just he was working with a beta version. However do try My First Project, which is nearly completed (I've got a bit more to finish on it, but it's 95% of the way there and useful already, in my opinion):

http://www.symfony-project.org/tutorial/1_1/my-first-project
halfer
Faithful Member
 
Posts: 10148
Joined: Mon Jan 30, 2006 1:16 pm
Location: West Midlands, UK

Re: Newbie - Day 2: 500 Internal Server error after click Create

by danwwilson » Mon Sep 08, 2008 1:01 pm

Rob,

From what I can gather (I only solved this one tonight too) you need to create a __toString() function in your user class. I had a look at Halfer's tutorial to get an idea of this.

In your /lib/model/User.php file you need to insert the following code:
Code: Select all
public function __toString()
{
  return $this->getTitle();
}


In the end the total contents of your User.php file should look like this:
Code: Select all
<?php

/**
 * Subclass for representing a row from the 'ask_user' table.
 *
 *
 *
 * @package lib.model
 */
class User extends BaseUser
{
  public function __toString()
  {
    return $this->getTitle();
  }
}


If this works please respond so that other users can get the benefits too.
danwwilson
Junior Member
 
Posts: 7
Joined: Sun Aug 17, 2008 8:49 am
Location: Melbourne

Re: Newbie - Day 2: 500 Internal Server error after click Create

by muzykagra » Tue Nov 04, 2008 3:40 pm

Yes, this solution works, thanks.
BTW someone should add this to tutorial to version v.1.1 ;]

Many people can get bored with symfony when something from tutorial get wrong.
muzykagra
Junior Member
 
Posts: 2
Joined: Tue Nov 04, 2008 3:30 pm

Re: Newbie - Day 2: 500 Internal Server error after click Create

by halfer » Tue Nov 04, 2008 6:55 pm

BTW someone should add this to tutorial to version v.1.1 ;]

Yes, I agree; it would be nice. I've just made a whole bunch of changes to the tutorial for 1.1, and I don't have time to re-do Askeet as well (which is a much larger project). Askeet is OK I think, so long as you're willing to do some digging/asking in the forums (if this puts you off, then symfony may have too steep a learning curve for you anyway). That said, I still agree it would be nice to have a more polished version.

Maybe a symfony developer off work with seasonal 'flu could spend some time on Askeet? :D~ :-D~ :grin:
halfer
Faithful Member
 
Posts: 10148
Joined: Mon Jan 30, 2006 1:16 pm
Location: West Midlands, UK

Re: Newbie - Day 2: 500 Internal Server error after click Create

by kluch » Fri Jul 31, 2009 3:20 pm

OMG tnx this help a fcuking lot :D~ :-D~ :grin:
kluch
Junior Member
 
Posts: 6
Joined: Fri Jul 31, 2009 9:43 am