Wednesday, May 27, 2015

Setting up the default Database to be UTF8

Setting up the default Database to be UTF8

One mistake even seasoned developers make when starting a Symfony project is forgetting to set up default charset and collation on their database, ending up with latin type collations, which are default for most databases. They might even remember to do it the very first time, but forget that it's all gone after running a relatively common command during development:

Setting UTF8 defaults for MySQL is as simple as adding a few lines to your configuration file (typically my.cnf):

# vim /etc/my.cnf

# Version 5.5.3 introduced "utf8mb4", which is recommended
collation-server     = utf8mb4_general_ci # Replaces utf8_general_ci
character-set-server = utf8mb4            # Replaces utf8

We recommend against MySQL's utf8 character set, since it does not support 4-byte unicode characters, and strings containing them will be truncated. This is fixed by the newer utf8mb4 character set.

# systemctl restart mariadb


Symfony / Doctrine:

# vim src/Mycomp/DemoBundle/Resources/config/doctrine/Product.orm.yml

    collate: utf8mb4_general_ci

# vim app/config/config.yml

        charset:  utf8mb4


How to VLOOKUP with Multiple Criteria Using INDEX and MATCH


Basically your match is saying look for "true" if these two conditions are both "true".

When you enter the formula, don’t just press ENTER. Press CTRL+SHIFT+ENTER to tell Excel that it is an array formula. You can tell you’ve done it right because the entered formula will be surrounded in curly braces {}.


Monday, May 25, 2015

Add embedded image in email through PHPMailer

Add embedded image in email through PHPMailer

  $mailer = new PHPMailer();

  $mailer->IsSMTP(); // telling the class to use SMTP
  $mailer->Host = 'localhost'; // SMTP server
  #$mailer->SMTPDebug = 2; // enables SMTP debug information (for testing)
                          // 1 = errors and messages
                          // 2 = messages only
  $mailer->Subject = 'My subject';
  $mailer->AddAddress($email, '');

  $mailer->SetFrom('', 'My Name');

  $html = '<img src="cid:logo">';

  $mailer->MsgHTML($html . "\n");

  $mailer->AddEmbeddedImage('/tmp/logo.png', 'logo', 'logo.png');

  if(!$mailer->Send()) {
    echo "[ERR] Mailer Error: " . $mailer->ErrorInfo . "\n";

Tuesday, May 12, 2015

Set up Symfony

Using mod_proxy_fcgi with Apache 2.4

If you are running Apache 2.4, you can easily use mod_proxy_fcgi to pass incoming requests to PHP-FPM. Configure PHP-FPM to listen on a TCP socket, enable mod_proxy and mod_proxy_fcgi in your Apache configuration and use the SetHandler directive to pass requests for PHP files to PHP FPM:

Note: mod_proxy_fcgi now supports network sockets since 2.4.9 ( Unix socket support for mod_proxy_fcgi ).

# vim /etc/httpd/conf.d/httpd-vhosts.conf

<VirtualHost *:80>
    ServerName domain.tld
    ServerAlias www.domain.tld

    # Uncomment the following line to force Apache to pass the Authorization
    # header to PHP: required for "basic_auth" under PHP-FPM and FastCGI
    # SetEnvIfNoCase ^Authorization$ "(.+)" HTTP_AUTHORIZATION=$1

    # For Apache 2.4.9 or higher
    # Using SetHandler avoids issues with using ProxyPassMatch in combination
    # with mod_rewrite or mod_autoindex
    <FilesMatch \.php$>
        SetHandler proxy:fcgi://

    # If you use Apache version below 2.4.9 you must consider update or use this instead
    # ProxyPassMatch ^/(.*\.php(/.*)?)$ fcgi://$1

    # If you run your Symfony application on a subpath of your document root, the
    # regular expression must be changed accordingly:
    # ProxyPassMatch ^/path-to-app/(.*\.php(/.*)?)$ fcgi://$1

    DocumentRoot /var/www/project/web
    <Directory /var/www/project/web>
        # enable the .htaccess rewrites
        AllowOverride All
        Require all granted

    # uncomment the following lines if you install assets as symlinks
    # or run into problems when compiling LESS/Sass/CoffeScript assets
    # <Directory /var/www/project>
    #     Options FollowSymlinks
    # </Directory>

    ErrorLog /var/log/apache2/project_error.log
    CustomLog /var/log/apache2/project_access.log combined


Run Symfony IP address 192.168.x.x

# php app/console server:run

Wednesday, May 6, 2015

To create a sitemap in Magento for Google Webmaster Tools

System > Configuration > Google Sitemap > Enabled > Yes

System > Configuration > Advanced > Mage_Sitemap > Enable

Catalog > Google Sitemap > Add Sitemap