Tuesday, November 23, 2010

Configure virtual host on linux to run symfony project

Let's assume you have created your project in /var/www/sfsite.

To create a virtual host for symfony project on Linux follow these steps:

sudo gedit /etc/apache2/sites-available/sfsite.lcl.conf - generate configuration for your new host

insert into file your settings of host:

<VirtualHost *:80>
    ServerName sfsite.lcl
    DocumentRoot "/var/www/sfsite/web"
    DirectoryIndex index.php
    <Directory /var/www/sfsite/web >
        AllowOverride All
    </Directory>
Alias /sf /var/www/symfony/data/web/sf
<Directory "/var/www/symfony/data/web/sf ">
AllowOverride All
Allow from All
</Directory>
</VirtualHost>

sudo a2ensite sfsite.lcl.conf – enable this site for the server

sudo gedit /etc/hosts

insert name of your host, so that your local server knows that it has to look in for your local sites, not on the internet:

127.0.0.1 sfsite.lcl

sudo /etc/init.d/apache2 restart – restart apache server and you can work on your symfony project by typing sfsite.lcl link into your web browser

Monday, November 22, 2010

Ubuntu 10.10 Can not Select Checkbox in Netbeans 6.9

After installing new version of Netbeans IDE 6.9 on Ubuntu 10.10, I had problem to select installing particular plugins. There were no possibility to tick a checkbox.

Problem was because Java Platform (java-6-open-jdk) is not Compatible with Ubuntu 10.10.
I solved the problem by uninstalling the newest all dependencies of jdk. 
The solution is to install sun-java6-jdk like this:

sudo apt-get install sun-java6-jdk

Then you can install Netbeans on your Ubuntu.

symfony: undefined method Doctrine_Collection::offset()

i got the following error when paginating results with sfDoctrinePager:
Fatal error: Call to undefined method Doctrine_Collection::offset() in /path/to/symfony/lib/plugins/sfDoctrinePlugin/lib/pager/sfDoctrinePager.class.php on line 84
if you're like me you'll think there's something wrong with symfony and search all over google and couldn't find anything.
this is not an error in symfony but could be in your own code.
in module action.class.php:
 
$this->pager->setQuery($this->getResult()); // you should return QUERY, not fetched array

Be sure you are returning from getReult() method query, not fetched array.
$q = Doctrine_Query::create()->from('Model m'); 
return $q;