Home | Mirror | SearchITEYE 博客 | OSChina 博客 | 51CTO 博客

第 7 章 Frameworks

目錄

7.1. Phalcon - High performance PHP framework
7.1.1. 安裝配置 Phalcon
7.1.1.1. 安裝擴展
7.1.1.2. Nginx 配置
7.2. Laravel - The PHP framework for web artisans.
7.3. CodeIgniter - Open source PHP web application framework
7.3.1. Nginx
7.3.2. PHP_CodeSniffer
7.4. Fuel PHP
7.4.1. 框架安裝
7.4.1.1. oil
7.4.1.2. Apache
7.4.1.3. Nginx
7.5. Kohana
7.6. Yii
7.7. Zend Framework
7.7.1. Install Zend Framework
7.7.2. Create Your Project
7.7.3. Create a virtual host
7.7.4. Database
7.7.4.1. MySQL
7.7.4.2. SQLite
7.7.5. zf.sh
7.7.5.1. controller
7.7.5.2. model
7.7.5.3. layout
7.7.5.4. form
7.7.6. Smarty
7.8. Propel
7.9. Doctrine
7.9.1. example

PHP Frameworks 比較

http://www.sitepoint.com/best-php-frameworks-2014/

7.1. Phalcon - High performance PHP framework

http://phalconphp.com/

與其他框架實現方法不同,Phalcon直接採用C代碼編寫,編譯成PHP共享庫載入。所以速度是最快的。

7.1.1. 安裝配置 Phalcon

7.1.1.1. 安裝擴展

			
cd /usr/local/src/
		
git clone git://github.com/phalcon/cphalcon.git
cd cphalcon/build
./install
		
cat > /srv/php/etc/conf.d/phalcon.ini <<EOF
extension=phalcon.so
EOF			
			
			

確認安裝是否成功

# php -m | grep phalcon
phalcon			
			

7.1.1.2. Nginx 配置

			
server {
    listen       80;
    server_name  localhost;

    charset utf-8;

    access_log  /var/log/nginx/host.access.log  main;

    location / {
        root   /www/phalcon/public;
        index  index.html index.php;
    		if ($request_filename !~ (js|css|img|/images|robots/.txt|index/.php) ) {
        		rewrite ^/(.*)$ /index.php?_url=/$1 last;
        		break;
    		}
    }

    #error_page  404              /404.html;

    # redirect server error pages to the static page /50x.html
    #
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/local/www/nginx-dist;
    }

    # proxy the PHP scripts to Apache listening on 127.0.0.1:80
    #
    #location ~ \.php$ {
    #    proxy_pass   http://127.0.0.1;
    #}

    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    #
    location ~ /index.php {
        root           /www/phalcon/public;
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  /www/phalcon/public$fastcgi_script_name;
        include        fastcgi_params;
    }

    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    #
    location ~ /\.ht {
        deny  all;
    }
}			
			
			

注意兩點:

一是rewrite設置需要 $request_filename 過濾檔案與目錄

二是location ~ /index.php 這樣的設置是為了".php"只能運行 index.php,其他目錄下的.php檔案無法運行,這樣解決的注入與非法腳本運行。

comments powered by Disqus