22
2009
Useful PHP Tools
19
2009
Converting MySQL Database to UTF-8
When we were building a WordPress website for a Chinese community we found even the configuration in WordPress defined default charset as 'UTF-8', becase the datbase tables/fields are by default not in 'utf8_unicode_ci', it won't allow users to post in Chinese the characters all come up as ? marks.
So we decide to alter all the tables and fields for WordPress to UTF-8, which would fix the problem. However it's not easy to change all the fields one by one from one charset and collation to another. Then we have written the following php script to help converting the tables and all text fields to UTF-8.
To set the MySQL default charset and collation to UTF-8, so the tables created later without any charset or collation specification would be default to UTF-8, please add these two lines to your my.cnf file under [mysqld],
character-set-server=utf8
default-collation=utf8_unicode_ci
17
2009
PHP Frameworks Comparison Test
The Test
We have each programmer picked a popular PHP framework, and the task is to setup the framework and create MVC for the benchmark, which involves,- 1000 database insertion
- 1000 database update
- query 1000 records (all fields), and display in a list
- each record size is about 2kb
- Pentium 4, 4.3GHz
- 2GB RAM
- Windows XP, SP3
- XAMPP 1.7.0 (patched to work with PDO)
- APC enabled (Zend Optimizer disabled)
- All programs turned off, including Anti-Virus and Firewall
The Result
Framework | Database Engine | Avg. Response Time | Avg. Memory Usage |
---|---|---|---|
Pure PHP | mysqli | 5.28s
|
0.14MB
|
oModel* | adodb mysql | 7.13s
|
6.88MB
|
Yii Framework (yiilite) |
pdo_mysql | 7.41s
|
8.38MB
|
Yii Framework | pdo_mysql | 7.7s
|
9.44MB
|
Kohana | mysqli | 7.68s
|
11.22MB#
|
Zend Framework | pdo_mysql | 8.37s
|
7.99MB
|
Zend Framework | mysqli | 11.28s
|
7.88MB
|
Akelos | mysqli | 12.98s
|
10.93MB
|
# With <benchmark> parameter turned off in the database config file, it only uses 1.5MB memory, and takes about 7.8s. Thanks Jeremy Bush for the advice. (updated 24/07/2009)
The Verdicts
Framework | Pro. | Con. |
---|---|---|
oModel | Fastest framework, light file structure, highly flexible, real short learning curve | Not as comprehensive, not well documented, no community support, need high skill set to work on for large-scale project |
Yii Framework | Fast, comprehensive, simple and secure file structure, strictly php5 OO, well documented, code generation | Farely new, still building community awareness |
Kohana | Flexibility, Easy start | Big memory footprint, DB feature incomplete |
Zend Framework | Great library set, flexible, best community support | Long learning curve, code generation problem* |
Akelos | Great RoR port, database migration | Slow, php4 |
The Conclusion
We understand this benchmark comparison is still bit off the real world, as it has too much emphasis on the database operation, where as in real web scenario the result can vary on different server deployment. Also, we didn't test cache mechanisms under each framework, which would play a real important role in the production environment, when server gets lot of hits on dynamic content, the result can be really different depend on project nature. Hopefully Orite will further test real web project taken most the core features of frameworks in consideration. If we were after speed, we would stick with oModel which had been the backbone of lots of recent Orite projects. After testing the frameworks, our team had picked both Zend Framework which has the most supportive community and feature set, and Yii Framework the good combination of comprehensive feature, ease of use and performance. We will start few project based on Yii Framework and continuously keep eyes and hands on Zend. Interesting findings regarding this topic will be posted after we have dived into these frameworks a bit more.16
2009
XAMPP 1.7.0 for Windows Problem
16
2009
Searching for The PHP Framework
- MVC pattern, since its what we familiar and happy with
- No non-sense folder structure, not too flexible or too restricted
- Solid and performance database abstraction layer, support transactions
- Good error handling and reporting
- URL management, routing and filtering
- Layered theme, layout, view
- Code generation
- Strict PHP5 implementation
- Good community support and active development
- Easy learning and start
- Performance and security
- Templating
- Ajax
- Caching
- Built-in useful libraries (validation, emailing, etc)
- Shell support for cron jobs
- I18n
- Database migration