PHP for Android

A few days ago was released a project to build applications based on Android with PHP.

This project allows us to build apps for Google’s operating system with the most popular scripting language (PHP). With this project the PHP developers will be able to run PHP in every device based on Android.

The phpforandroid.net project was build over the Android Scripting Environemnt (ASE) which was renamed to Scripting Layer for Android (SL4A), which allows developers to run scripting languages like PHP and Phyton.

The project is at its beginning and for sure it will evolve with the time and the community’s help. I was playing a little bit and it works perfectly so far.

The project also has a really good documentation and we can use an Android emulator to test out apps.

Here there is a video that shows how phpforandroid works:

Use utf8 in Symfony with Doctrine

Here we will see how to configure Doctrine to use utf8 in Symfony.

So, we will set the charset and the collation of our database to use utf8, which most of the time is very useful, for instance, when we want to use a database with support to internationalization (i18N).

To do that we have three possibilities to see:

First, we can edit the config/ProjectConfiguration.class.php file:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
<?php
class ProjectConfiguration extends sfProjectConfiguration
{
    public function setup()
    {
        $this->enablePlugins('sfDoctrinePlugin');
    }

    public function configureDoctrine(Doctrine_Manager $manager)
    {
        $manager->setCollate('utf8_unicode_ci');
        $manager->setCharset('utf8');
    }
}

The second one is to set the configuration in the config/databases.yml file:

1
2
3
4
5
6
7
8
9
10
11
all:
  doctrine:
    class: sfDoctrineDatabase
    param:
      dsn:      mysql:host=localhost;dbname=myDatabase
      username: myUser
      password: mySecret
      attributes:
        default_table_type:    InnoDB
        default_table_collate: utf8_unicode_ci
        default_table_charset: utf8

And the last one is to set the options in our schema (config/doctrine/schema.yml):

1
2
3
4
options:
  collate: utf8_unicode_ci
  charset: utf8
  type: InnoDB

I hope this is helpful for you.