Thursday, September 20, 2012

MySQL Tuning

  1. Optimize tables (to correct overheads)
  2. Set query cache size bigger if Qcache_lowmem_prunes (on the runtime information page) is red.
Useful commands:

  • Show all query cache settings:
    SHOW VARIABLES LIKE  '%query_cache%';
  • Set a bigger query cache size (256 MB) ON RUNTIME:
    SET GLOBAL query_cache_size = 256000000;
  • Set a bigger query cache size in config (will work after mysql restart):
    /etc/mysql/my.cnf
    Search for "query_cache_size" then change...
    query_cache_size = 256M

Saturday, September 15, 2012

Install Symfony 2 on Debian

  1. Download the Standard version and put the Symfony folder to the root.
  2. Open /Symfony/web/config.php with browser to check the configuration. If needed, remove the ip address check from the begining of the file. I had to install things and do some changes:

    apt-get update
    apt-get install php-pear php5-dev apache2-threaded-dev build-essential libicu-dev
    pecl install apc
    pecl install intl

    php.ini:
    short_open_tag = Off
    date.timezone = Europe/Budapest (for me)
    extension = apc.so
    extension = intl.so


    Save then restart apache.

Friday, September 14, 2012

Filter Data On Frontend with Symfony Form Filter

Source: http://stackoverflow.com/questions/3765495/symfony-how-to-filter-data-on-the-frontend-like-in-the-backend

If you want to do it exactly like it is done on the backend, you can use the admin generator on frontend applications. A more general and customizable way would be to simply create list and filter actions and use Symfony's form filters. Here's a basic example for a model class "Article":

In an actions class:
class articleActions extends sfActions
{
  public function executeList(sfWebRequest $request)
  {
    $this->form = new ArticleFormFilter();
    $this->pager = new sfDoctrinePager('Article');
  }

  public function executeFilter(sfWebRequest $request)
  {
    $this->form = new ArticleFormFilter();
    $this->form->bind($request[$this->form->getName()]);
    if ($this->form->isValid())
    {
      $this->pager = new sfDoctrinePager('Article');
      $this->pager->setQuery($this->form->getQuery());
      $this->setTemplate('list');
    }
    //handle invalid form here
  }
}
In view, iterate throw pager like this:
foreach($pager->getResults() as $article)
Doctrine FormFilter's are fairly similar to Doctrine forms. Get started by configuring the form inside of FormFilter::configure();

ob_start: PHP Output To Variable / String

<?php ob_start(); ?>
Hello world, <?php echo "My Website"; ?>
<?php include('something.php') ?>
Thank you.
<?php $var = ob_get_clean(); ?>

Friday, September 7, 2012

The user specified as a definer ('root'@'%') does not exist

Solution:
mysql -u root -p
grant all privileges on *.* to `root`@`%` identified by 'password';
flush privileges;

Install Apache 2, PHP 5, MySQL 5 on Debian

apt-get update

apt-get install apache2
apt-get install php5
apt-get install libapache2-mod-php5
apt-get install mysql-server mysql-client mysql-common php5-mysql
apt-get install php5-xsl php5-gd php5-curl

Install the Latest APC on Debian
Install PHPMYADMIN on Debian

Install PHPMYADMIN on Debian

1. Download the latest PHPMYADMIN.
2. Put here: /usr/share/phpmyadmin
3. Create phpmyadmin.conf in /etc/apache2/conf.d :
Alias /phpmyadmin /usr/share/phpmyadmin


        Options Indexes FollowSymLinks
        DirectoryIndex index.php

4. /etc/init.d/apache2 restart