Showing posts with label Symfony. Show all posts
Showing posts with label Symfony. Show all posts

Tuesday, December 22, 2009

Fatal error: Allowed memory size of 33554432 bytes exhaustsed

when follow the Jobeet tutorial to Day 9, functional test,  got problem with the following test:
php symfony test:functional frontend
categoryActionsTest..................................................dubious
    Test returned status 139
    Failed tests: 0
jobActionsTest.......................................................dubious
    Test returned status 139
    Failed tests: 0
Failed Test                     Stat  Total   Fail  List of Failed
------------------------------------------------------------------
categoryActionsTest              139      1      1  0
jobActionsTest                   139      1      1  0
Failed 2/2 test scripts, 0.00% okay. 2/0 subtests failed, 0.00% okay.  

went further to teste the code one by one then found the fatal error:
php symfony test:functional frontend categoryActions
> 1 - The category page
>   1.1 - Categories on homepage are clickable
# get /

Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 30720 bytes) 
in /home/ddd/projects/jobeet/lib/vendor/symfony/lib/helper/PartialHelper.php on line 148

went to /etc/php5/apache2 to edit php.ini to change the memory limit to 128M then restart apache it didn't help.
went to /etc/php5/cli to edit php.ini to change the memory limit to 128M then restart apache, it only pass 3 tests then threw Segmentation fault again...

added the following in front the test code
$browser->with('response')->debug; 
and run test again, the response debug showed there were too many job records returned(about 30 jobs), that's why memory was running out?

Tuesday, December 15, 2009

symfony: doctrine couldn't locate driver named mysql

followed the symfony's tutorial at chapter 3, when performed the command: php symfony doctrine:insert-sql, it complained:
doctrine created tables successfully
Couldn't locate driver named mysql

go check php.ini file, pdo_mysql was enabled:  extension=pdo_mysql.so
but when go into folder /etc/php5/conf.d/, only found: pdo.ini, xsl.ini and zend-framework.ini, so maybe pdo_mysql extension was actually not installed?

try to install pdo_mysql extension again:
sudo pecl install pdo_mysql
Ignoring installed package pecl/pdo_mysql
Nothing to install
uninstalled and reinstalled pecl/pdo_mysql wont' help.

searched around and found the solution here.
Odds are that your php.ini file for your CLI (often different from the apache php.ini) 
doesnt have pdo_mysql enabled. Enable it :)  

edit /etc/php5/cli and add the following to the end:
extension=pdo.so
extension=pdo_mysql.so
extension=apc.so
restarted apache and it works!

Saturday, December 12, 2009

install symfone on ubuntu

Try to install symfony on ubuntu:

Follow the get-started tutorial on symfony's website at:http://www.symfony-project.org/getting-started/1_4/en/02-Prerequisites,

run check_configuration.php in the web browser: http://localhost/check_configuration.php and it threw the following result:
********************************
*                              *
*  symfony requirements check  *
*                              *
********************************

php.ini used by PHP: /etc/php5/apache2/php.ini


** Mandatory requirements **

  OK        PHP version is at least 5.2.4 (5.2.6-3ubuntu4.2)

** Optional checks **

  OK        PDO is installed
[[WARNING]] PDO has some drivers installed: : FAILED
            *** Install PDO drivers (mandatory for Propel and Doctrine) ***
  OK        PHP-XML module is installed
[[WARNING]] XSL module is installed: FAILED
            *** Install the XSL module (recommended for Propel) ***
  OK        The token_get_all() function is available
  OK        The mb_strlen() function is available
  OK        The iconv() function is available
  OK        The utf8_decode() is available
[[WARNING]] A PHP accelerator is installed: FAILED
            *** Install a PHP accelerator like APC (highly recommended) ***
  OK        php.ini has short_open_tag set to off
  OK        php.ini has magic_quotes_gpc set to off
  OK        php.ini has register_globals set to off
  OK        php.ini has session.auto_start set to off
  OK        PHP version is not 5.2.9
To fix the first warning, install PDO package for PHP 5 on ubuntu:
sudo apt-get install libmysqlclient15-dev
sudo pecl install pdo

then got the following message:
downloading PDO-1.0.3.tgz ...
Starting to download PDO-1.0.3.tgz (52,613 bytes)
.............done: 52,613 bytes
12 source files, building
running: phpize
sh: phpize: not found
ERROR: `phpize' failed
googled around and found out that need to install php5-dev version, so here we go:
sudo apt-get install php5-dev
sudo pecl install pdo
at the end of the installation, it displayed:
Build process completed successfully
Installing '/usr/include/php/ext/pdo/php_pdo.h'
Installing '/usr/include/php/ext/pdo/php_pdo_driver.h'
Installing '/usr/lib/php5/20060613/pdo.so'
install ok: channel://pecl.php.net/PDO-1.0.3
configuration option "php_ini" is not set to php.ini location
You should add "extension=pdo.so" to php.ini
sudo pecl install pdo_mysql
at the end of installation, it displayed:
Build process completed successfully
Installing '/usr/lib/php5/20060613/pdo_mysql.so'
install ok: channel://pecl.php.net/PDO_MYSQL-1.0.2
configuration option "php_ini" is not set to php.ini location
You should add "extension=pdo_mysql.so" to php.ini
edit php.ini at /etc/php5/apache2/ to add the above 2 lines, restart apache: sudo /etc/init.d/apache2 restart
and check the configuration again in the browser, boo! the first warning is gone!  so far so cool :)
sudo apt-get install php5-xsl
sudo /etc/init.d/apache2 force-reload
then rerun check configuration in browser, yeah, second warning is gone!!!!

to fix the third warning, run:
sudo pecl install apc
and edit php.ini to add 'extension= apc.so', then restart apache2. check the configuration in browser, hola, it's all gone, all the warnings!!!

now can go ahead to have fun with symfony!