Symfony

Symfony2 optional requirements installation on Mac OS X

intl extension

Use “port” to install php5-intl

sudo port install php5-intl

Copy intl.so into active php extensions directory

sudo cp /opt/local/lib/php/extensions/no-debug-non-zts-20090626/intl.so /usr/lib/php/extensions/no-debug-non-zts-20090626/

Add “extension=intl.so” into php.ini

sudo nano /etc/php.ini

Restart apache

sudo apachectl restart

Install MacPorts

Download Mac OS X Package (.pkg) Installer, http://www.macports.org/install.php By default port is installed the directory /opt/local/bin. To correct PATH issue add the path /opt/local/bin as an extra line to the plain text file /etc/paths To keep your MacPorts system always current

sudo port -v selfupdate

Install Xcode

Open AppStore, search and install Xcode. To install Command Line Tool components for Xcode, go to Xcode Preferences and click Downloads tab. You will see Command Line Tools and install it.

Memcache

Install memcached

sudo port install memcached

Set memcached to load on startup

sudo port load memcached

Install the php5 module

sudo port install php5-memcache

Copy the newly created shared object for memcache into Mac OS X’s default PHP5 extension directory

sudo cp /opt/local/lib/php/extensions/no-debug-non-zts-20090626/memcache.so /usr/lib/php/extensions/no-debug-non-zts-20090626/

Add extension to php.ini

extension=memcache.so

Restart apache

sudo apachectl restart

PHP Accelerator (APC)

Install the php5 module

sudo port install php5-apc

Copy the newly created shared object for APC into Mac OS X’s default PHP5 extension directory

sudo cp /opt/local/lib/php/extensions/no-debug-non-zts-20090626/apc.so /usr/lib/php/extensions/no-debug-non-zts-20090626/

Add extension to php.ini

extension=apc.so

Restart apache

sudo apachectl restart

Using multiple databases in Symfony2

Edit app/config/config.yml

# Doctrine Configuration
doctrine:
    dbal:
        default_connection:       default
        connections:
            default:
                dbname:           db1
                user:             user1
                password:         pwd1
                host:             192.168.2.102
            forum:
                dbname:           db2
                user:             user2
                password:         pwd2
                host:             192.168.2.102
    orm:
        auto_generate_proxy_classes: %kernel.debug%
        default_entity_manager: default
        entity_managers:
            default:
                connection: default
                auto_mapping: true
                metadata_cache_driver: apc
                query_cache_driver: apc
                result_cache_driver: apc
            forum:
                connection: forum
                mappings:
                    DevDreamBundle: ~

Controller

$query = $this->get('doctrine')->getEntityManager('forum')->createQuery("SELECT th FROM DevDreamBundle:devdreamUser th")->setMaxResults(4)->getResult();