effective life plus

Binzy's blog

深入PHP :面向对象,模式与实践

| Filed under Programming

书终于在上个月出版了,而我对翻译的记忆的细节已经完全模糊了,只依稀记得那是从2007年到2008年。刚开始的时候是第一版,然后第二版出来了,然后继续翻译,因为2版之间区别不大。大部分的时间都是haohappy在沟通和协调,而我仅是负责我的那部分。虽然我也已然记不大清我具体负责了哪几章,大体是模式那部分。书最终还是出版了,虽然有读者抱怨说原书第三版已然出版,但我还是想说,虽然是第二版,书还是好书。这本书是为数不多的把面向对象,模式及相关良好实践阐述的比较清晰和深人,并且按照PHP的方式来阐述的书。虽然书中的一部分内容,现在看来有些许过时,但理论是一致的。大部分应用软件开发的成本如果不计质量(当然也不计研发),那主要在于单位时间的人力成本及时间总量。而优秀的设计,模式和实践都有助于降低成本及提高或保持质量。

原书的第三版从目录来看,更新了一些有些过时的内容,比如版本管理从CVS改为SVN,针对PHP5.3的一些新特性添加了一些内容,并且加入了持续集成这样的重要敏捷元素章节。

不得不说,翻译比我想象的要累得多。不仅要考虑到原作的表达,也要符合中文的习惯。希望我的翻译不是太糟糕。
更多关于本书,可前往douban等网站,也希望大家多批评指正。

nginx + Zend Framework @ Windows

| Filed under Programming

If you feel pretty boring with Apache, just like me, so having a try of nginx might be good idea. Although at most of my time, I’m using Windows, fortunately, nginx has native Windows build. So my steps might be helpful to you to try nginx on Windows, especially Windows 7.

1. Download nginx and php and install

2. Configure nginx and php

  • PHP, no specific configuration, just do what you like to php.ini.
  • Nginx
    Fast-CGI of php
    You can find sample from wiki.nginx.org, http://wiki.nginx.org/PHPFastCGIOnWindows, below works for me.
    location ~ \.php$ {
                fastcgi_pass   127.0.0.1:9999;
                fastcgi_index  index.php;
                fastcgi_param  SCRIPT_FILENAME  D:/www/public/$fastcgi_script_name;
                include        fastcgi_params;
            }

    Configure for Zend Framework
    -f and !-f are used for checking whether file exists.
            error_page 404 /index.php;
    
            if (!-f $request_filename) {
                rewrite ^.*$ /index.php last;
                break;
            }

3. batch script to start and stop nginx + php-cgi

I’m using RunHiddenConsole to hide the prompt window and actually you also can use vbs to run nginx.

start-nginx.bat

@ECHO OFF
ECHO Starting PHP FastCGI...
C:\nginx\RunHiddenConsole.exe C:\PHP5\php-cgi.exe -b 127.0.0.1:9999
ECHO Starting nginx...
C:\nginx\RunHiddenConsole.exe c:\nginx\nginx.exe

stop-nginx.bat
@ECHO OFF
ECHO Stopping nginx...
taskkill /F /IM nginx.exe
ECHO Stopping php-cgi...
taskkill /F /IM php-cgi.exe

but php-pfm doesn’t work on Windows unless you are using cygwin.

nginx_zend

Zend Framework Multiple Helper Path Configuration

| Filed under Programming

As you may have multiple configuration for helpers of Zend View, simply configure as below will help

resources.view.helperPath.Zend_View_Helper = APPLICATION_PATH "/views/helpers"
resources.view.helperPath.My_Custom_Helper = "/path to helpers"

The “My_Custom_Hepler” is the prefix, so that you can support your different modules’ help path without hard coding in php codes.