Google

星期四, 五月 14, 2009

微软为Azure准备PHP开发包

微软刚刚为Azure Cloud项目添加了一个重要的PHP SDK,这可以允许测试者们建立PHP应用到云计算平台.

在TechEd印度站,微软公布了这款SDK,它是一个开源项目,源码可以在Microsoft CodePlex上找到,可以提供与Azure一致的编程模型(块,表&队列).包括Silverlight控制,Virtual Earth地图,IE Webslices and Accelerators均可被调用,预计该SDK正式版将在8月发布.

http://phpazure.codeplex.com/

 在TechEd印度站,微软公布了这款SDK,它是一个开源项目,源码可以在MicrosoftCodePlex上找到,可以提供与Azure一致的编 程模型(块,表&队列).包括Silverlight控制,VirtualEarth地图,IEWebslices and Accelerators均可被调用,预计该SDK正式版将在8月发布。

  相关阅读

   Windows Azure是微软基于云计算的操作系统,和AzureServicesPlatform一样,是微软“软件和服务”技术的名称。WindowsAzure 的主要目标是为开发者提供一个平台,帮助开发可运行在云服务器、数据中心、Web和PC上的应用程序。云计算的开发者能使用微软全球数据中心的储存、计算 能力和网络基础服务。Azure服务平台包括了以下主要组件:WindowsAzure;MicrosoftSQL数据库服 务,Microsoft.Net服务;用于分享、储存和同步文件的Live服务;针对商业的MicrosoftSharePoint和 MicrosoftDynamics CRM服务。

  Windows Azure能运行什么?

  目前微软公布的版本属于社区技术预览版,它缺乏一些微软即将加入的元素。只有使用托管代码编写的程序,必须包括.NET,才能在这个系统上运行。要能 运行本机代码,必须等到明年发布的版本。Azure目前只能运行在微软的单一数据中心上,明年微软将把范围扩大到美国的其他数据中心,甚至海外。微软高管 BobMuglia称,实际上微软在一年内不会部署太多的程序在上面,因为还有很多东西需要去学习。

来源:http://linux.chinaunix.net/news/2009/05/14/1111354.shtml

标签: ,

星期四, 三月 26, 2009

OpenID 是什么?

OpenID 是一个以用户为中心的数字身份识别框架,它具有开放、分散、自由等特性。

OpenID 的创建基于这样一个概念:我们可以通过 URI (又叫 URL 或网站地址)来认证一个网站的唯一身份,同理,我们也可以通过这种方式来作为用户的身份认证。 由于URI 是整个网络世界的核心,它为基于URI的用户身份认证提供了广泛的、坚实的基础。

OpenID 系统的第一部分是身份验证, 即如何通过 URI 来认证用户身份。 目前的网站都是依靠用户名和密码来登录认证,这就意味着大家在每个网站都需要注册用户名和密码, 即便你使用的是同样的密码。如果使用 OpenID (参见规范), 你的网站地址(URI)就是你的用户名, 而你的密码安全的存储在一个 OpenID 服务网站上 (你可以自己建立一个 OpenID 服务网站,也可以选择一个可信任的 OpenID 服务网站来完成注册)。

登录一个支持 OpenID 的网站非常简单(即便你是第一次访问这个网站也是一样)。 只需要输入你注册好的 OpenID 用户名,然后你登录的网站会跳转到你的 OpenID 服务网站, 在你的 OpenID 服务网站输入密码(或者其它需要填写的信息)验证通过后, 你会回到登录的网站并且已经成功登录。 OpenID 系统可以应用于所有需要身份验证的地方, 既可以应用于单点登录系统,也可以用于共享敏感数据时的身份认证。

除了一处注册,到处通行以外,OpenID 给所有支持 OpenID 的网站带来了价值--共享用户资源。 用户可以清楚的控制哪些信息可以被共享,例如姓名、地址、电话号码等。

今天,OpenID 作为以用户为中心的身份验证系统已经为数百万的用户提供了服务。 在“I Want My OpenID Bounty” 项目的推动下, 许多开源项目都迅速的加入了对 OpenID 的支持。

http://openid.net.cn/
http://openid.net/

标签: , ,

星期二, 六月 03, 2008

php+xapian extension的安装

xapian是啥玩意?

xapian 是一个“Xapian 是一个开源概率论信息检索库,基于GPL发布。它是用C++编写的,提供的绑定可以支持其它语言(支持Perl, Python, PHP, Java, and TCL )的开发。 Xapian 设计为一个高度可适应的工具集,可以让开发人员方便地为他们自己的应用程序增加高级索引和搜索功能。”

在网上找到这段介绍后,俺手痒痒就想试试xapian —- 一定要给php整个这东东上去.参考了若干文档以后,这就开始动手了(我的环境仍然是freebsd + apache 2.2 + php 5.1.2,apache和php原来就已经安装好):

1.下载xapian

cd /usr/local/src
wget http://www.oligarchy.co.uk/xapian/0.9.4/xapian-core-0.9.4.tar.gz
wget http://www.oligarchy.co.uk/xapian/0.9.4/xapian-bindings-0.9.4.tar.gz

前者是xapian的核心lib代码,后者是给其它语言调用的接口

2.安装Xapian-core

cd /usr/local/src
tar xzvf xapian-core-0.9.4.tar.gz
cd xapian-core-0.9.4
./configure –prefix=/usr/local/xapian
make
make install

3.安装Xapian-bindings

cd /usr/local/src
tar xzvf xapian-bindings-0.9.4.tar.gz
cd xapian-bindings-0.9.4
ln -s /usr/local/xapian/bin/xapian-config /usr/local/bin/xapian-config #这里需要做个软连接,编译的时候需要用到
./configure –without-python #我没用到python,就不编译了
make
make install

进行到这一步,Xapian-bindings应该算是安装好了,但是不知道为何,编译好的xapian.so没有按说明文档所说的自动复制到php的extension目录,于是我手工完成这一步骤

cp php/.libs/xapian.so /usr/local/lib/php #/usr/local/lib/php是我在php.ini设置的extension目录

然后修改php.ini
extension_dir = “/usr/local/lib/php/” #没有就加上
extension=xapian.so

安装全部完成,重启apache看看phpinfo:

php + xapian extension
一切ok:)


http://my.bymg.net/2007/08/31/phpxapian-extension%E7%9A%84%E5%AE%89%E8%A3%85/

标签: , ,

星期三, 五月 14, 2008

使用CodeIgniter框架快速开发PHP应用:分析网站结构(1)

转贴自CI中国

分析网站结构

既然我们已经安装 CI ,我们开始了解它如何工作。
读者已经知道 CI 实现了MVC式样。 通过对目录和文件的内容进行分类, 而不是让代码大块大块地纠集在一起。
这一章,我们将会对 MVC 理论做个简短的介绍, 然后再介绍 CI 的MVC实现方式。特别地,要了解那些目录和文件如何互相交换信息?网站结构是怎样的?以及CI是如何自如地动作于其中的?

这一章将会介绍:

。MVC 如何架构一个动态网站
。CI如何接收和分析request以及如何调配指定的代码来reponse
。这些指定的代码如何编制
CodeIgniter 语法
。CI提供的各种类和函数,你自己编写的类和函数
。如控向controllers传递URL参数
。如何编写运行良好的视图并把动态内容传递给它们。
。如何返回信息给上网者
。文件和类如何传递信息和互相调用
。助手类文件有什么用?
。有助于网站设计的一些特别提示

MVC-到底有什么用?

MVC,在本文领域内,指的是一个动态网站的组织方法。 设计模式是1979年由挪威人,Trygve Reenskaug首次提出来的,这里是一些概要:
。模型是包含数据的对象,他们与数据库交互,对这些数据进行存取,使其在不同的阶段包含不同的值,不同的值代表了不同的状态,具有特定的含意。
。视图显示模型的状态,他们负责向使用者显示数据。(虽然他们通常是 HMTL 视图, 但是,他们可能是任何形式的接口。 比如PDA屏幕或WAP手机屏幕)
。控制器用来改变模型的状态,他们操作模型,提供动态的数据给视图。
CI框架包含模型、视图和控制器的子目录。 他们里面的每个文件都有.php文件后缀, 包含有特定命名约定的类。
CI 帮助你遵循MVC的约定, 使你更有效地组织代码。 CI允许你有最大的灵活性,你可以获得 MVC 结构的所有好处。
当你编程的時候,试着始终用 MVC 来思考问题。尽可能确保你的 ‘视图’ 聚焦于显示, ’控制器’纯粹地用来控制数据流。 把应用逻辑保留在数据模型和数据库中。

这样,如果你决定开发新的视图,你不必在任何一个控制器或模型中修改代码。 如果你需要更新 ‘商业规则’ ,你只需要在模型中修改代码。

标签: , ,

;)

C/C++还是最棒的

Object Pascal也不错,至少目前Free Pascal的发展比Delphi的命运好像好一点

Python易学易用,语法太灵活了,缩进还是没有;号爽

UML 2.0还没有达到易用,易懂的程度,也许以后描述问题不用它了吧

PHP做网站很不错,CodeIgniter框架也不错,就是对XHTML的支持,特别是UTF-8的支持不是很理想。

标签: , , , , , , ,

25个顶级PHP模板引擎

为了找到一个好的模板引擎,我在互联网上进行搜索,目前已经整理出了以下名单:

Smarty
Smarty的特点是将模板编译成PHP脚本,然后执行这些脚本。很快,非常灵活。

Heyes Template Class
一个非常容易使用,但功能强大并且快速的模板引擎,它帮助你把页面布局和设计从代码中分离。

FastTemplate
一个简单的变量插值模板类,它分析你的模板,把变量的值从HTML代码中分离处理。

ShellPage
一个简单易用的类,可以让你的整个网站布局基于模板文件,修改模板就能改变整个站点。

STP Simple Template Parser
一个简单、轻量级并且易于使用的模板分析类。它可以从多个模板中组装一个页面,把结果页面输出到浏览器或者文件系统。

OO Template Class
一个你可以用在自己程序中的面向兑现的模板类。

SimpleTemplate
一个可以创建和结构化网站的模板引擎。它可以解析和编译模板。

bTemplate
短小但是快速的模板类,允许你把PHP逻辑代码从HTML修饰代码中分离。

Savant
一个强大且轻量级的PEAR兼容模板系统。它是非编译型的,使用PHP语言本身做为它的模板语言。

ETS - easy template system
可以使用完全相同数据重组模板的模板系统。

EasyTemplatePHP
适用于你的站点的一个简单但是强大的模板系统。

vlibTemplate
一个快速、全能的模板系统,它包含一个缓存和调试类。

AvanTemplate
多字节安全的模板引擎,占用很少系统资源。它支持变量替换,内容块可以设置显示或隐藏。

Grafx Software’s Fast Template
一个修改版本的Fast Template系统,它包括缓存功能,调试控制台以及沉默去除为赋值块。

TemplatePower
一个快速、简单、功能强大的模板类。主要功能有嵌套的动态块支持,块/文件包含支持以及显示/隐藏未赋值的变量。

TagTemplate
这个库的功能被设计来使用模板文件,同时允许你从HTML文件检索信息。

htmltmpl: templating engine
一个适用于Python和PHP的模板引擎。它面向希望在项目中分离代码和设计的web应用开发人员。

PHP Class for Parsing Dreamweaver templates
一个分析Dreamweaver模板的简单类,被用于Gallery 2 和WordPress的自定义模块中。

MiniTemplator (Template Engine)
针对HTML文件的一个紧凑型模板引擎。对于模板变量和块定义它具有简单的语法。其中块可以嵌套。

Layout Solution
简化网站开发和维护。它拥有常用的变量和页面元素使你不需要重复做页面布局工作。

Cached Fast Template
它已经纳入 FastTemplate ,允许你缓存模板文件,甚至可以在分离的块内容上缓存不同的规格。

TinyButStrong
一个支持MySQL, Odbc, Sql-Server和ADODB的模板引擎。它包含7个方法和两个属性。

Brian Lozier’s php based template engine
只有2K大小,非常快并且是面向对象设计。

WACT
一个从设计中分离代码的模板引擎。

PHPTAL
一个PHP下面的XML/XHTML模板库。

http://www.yeeyan.com/articles/view/2930/1993

标签: , , , , , , ,

PHP 6 的新特性

PHP的下一个版本,V6,包含了很的新特性和语法改进,会使它在面向对象方面性更易用。其他重要的特性:比如在核心函数中对Unicode (统一编码)的支持,这意味着 PHP 6提供了更好的更可靠国际支持。

PHP已经很流行,被无数的站点使用,被大部分因特网接入商所支持,被Yahoo这样的大网络公司使用着。在即将来临的PHP版本中准备增加一些成功的新特性,使PHP在某些场合下更易用更安全。你准备好接受 PHP 6 了吗?如果你明天就升级了,你的程序会运行得很好吗?你该怎么办?这篇文章集合了PHP 6的改变,他们中的一些备份移植到版本的PHP v5.x,您目前的脚本可能需要进行一些调整。

如果你现在使用不是PHP,但是一直在考虑它,考虑一下它的新特性。这些特点,从Unicode的核心支持到XML支持,使它更容易为你写的功能填补PHP的应用。

PHP 6 新特性

PHP 6当前已经作为开发者快照使用,所以你可以下载和试用一下这篇文章列出很多特性,这些特性已经在当前的快照中实现了。见资源

改进 Unicode 支持

在PHP的核心函数中,有很多对Unicode 字符串的支持的改进,这些新特性将产生巨大的影响因为它允许PHP为国际字符提供更多的支持。所以如果一个开发者或者架构师使用不同的语言,例如Java程序语言,是因为它具有超过PHP的国际化支持的话,当支持改进时他会花一点时间来考虑一下PHP。

因为今天你已经可以下载到开发者版本的 PHP V6,你将看到一些功能函数已经支持Unicode字符串。有一个函数清单已经被测试和验证了完全可以处理Unicode,参见资源

命名空间

命名空间是一种避免因函数或者类之间的命名冲突而使你的函数和类以及方法无法读取,而不使用前缀命名惯例的一种方法。因此,通过使用命名空间,你可以命名别人可能已经使用的类名,而不用担心在运行时会出错。表一提供了一个在PHP中使用命名空间的示例。

您不用在源代码中做更新或更改,因为你写的任何PHP代码可以不包含命名空间而运行得很好。因为命名空间特性似乎会移植到PHP 5.3 X中,如果它可以使用,您可以在自己的程序中引用命名空间。

表一,命名空间示例

php
// I'm not sure why I would implement my own XMLWriter, but at least
// the name of this one won't collide with the one built in to PHP
namespace NathanAGood;
class XMLWriter
{
// Implementation here...
}

$writer = new NathanAGood::XMLWriter();

?>

Web 2.0 特性

依赖于你怎么使用PHP和你现在脚本的是什么样子的,现在的语言和语法差异,可能会或者不会最大程度的影响下面一些特性,这是指那些直接让你引用的Web 2.0功能到你的PHP应用程序。

SOAP

SOAP是一种网络服 务“说话”的协议,并且支持不少其他语言,例如Java和微软的.NET,虽然有其他的方法来驱动和使用网络服务,比如 表象化状态转变(Representational State Transfer )REST,SOAP仍然在使不同平台具有可操作性中是最常用的。此外,SOAP在PHP扩展和PEAR库中使用,SOAP在PHP中默认是不支持的,因 此你启用这个扩展或者叫你的ISP启用。此外,PEAR包允许你建立SOAP客户端和服务器,如SOAP包。

如果你改变了默认设置,SOAP将会在PHP 6中启用。这个扩展将提供你很容易的的实现SOAP客户端和SOAP服务,允许你编写的应用提供使用或者网络服务。

如果SOAP扩展是默认设置,那就意味着你不能在PHP中设置它们,如果您开发的PHP应用程序并且它们发布到一个ISP服务器上,您可能需要检查一下你的ISP,以验证SOAP并启用为他们升级。

XML

在PHP 5.1中XMLReader 和XMLWriter已经变成PHP核心的一部分,这使你工作起来更轻松如果在你的PHP程序中需要使用到XML的话。和SOAP扩展一样,如果你使用SOAP或者XML这是个好消息因为PHP 6比已经出炉的PHP4 更适合你。

被删除的东西

除了具有的一些新功能,PHP 6引擎将删除一些在前面版本中已经有的功能。大部分这些功能,如register_globalssafe_mode 在目前的PHP中被视为“破的”。因为他们可能会暴露一些安全风险。PHP在努力的清除中,在下一个版本中这些将从PHP中删除或者废弃。反对者认为大部分ISP或者企业会保留现在的脚本因为升级到PHP6会破坏现在的的脚本,但是支持者认为很高兴看到PHP团队修补了这些漏洞,并且提供了一个干净,安全的运行工具。

将从PHP删除的功能有:

magic_quotes register_globals register_long_arrays safe_mode

http://www.yeeyan.com/articles/view/muxi/7659

标签:

星期六, 五月 10, 2008

如何通过smarty生成静态化网页

Smarty最大的功能是做模版的页面缓存。也就是通过Smarty可以完成两个步骤:编译+解析

第一步:编译。是指把模版文件的标签替换为纯php,再保存在缓存位置,保存的文件扩展名是PHP,我把这个步骤叫做编译(这是我自己的叫法,不是官方的)

第二步:解析。也就是把刚才编译的PHP文件解析执行而已~~这个就不用多做解释了

切入正题,在Smarty.class.php文件中加入如下代码

function MakeHtmlFile($file_name, $content)
{ //目录不存在就创建
if (!file_exists (dirname($file_name))) {
if (!@mkdir (dirname($file_name), 0777)) {
die($file_name."目录创建失败!");
}
}

if(!$fp = fopen($file_name, "w")){
echo "文件打开失败!";
return false;
}


if(!fwrite($fp, $content)){
echo "文件写入失败!";
fclose($fp);
return false;
}

fclose($fp);
chmod($file_name,0666);
} 这个函数的作用就是保存文件~~

调用方法如下

require '../libs/Smarty.class.php';


$smarty = new Smarty;


//…………省略变量定义和赋值


//$smarty->display('index.tpl');
$content=$smarty->fetch("index.tpl");

$smarty->MakeHtmlFile('./index.html',$content);//生成

http://hi.baidu.com/anvycn/blog/item/a313761ec50fbaf01bd5768d.html

标签: , , , ,

星期四, 五月 01, 2008

CodeIgnitor,管理你的应用程序

默认情况下,你会将应用程序放入system/application/中,并且可能用 CodeIgniter 只管理这一个应用程序。当然,多个应用程序共享一个 CodeIgniter, 甚至对 application 文件夹进行重命名或更换路径也是可行的。

对应用程序文件夹重命名

如果你要对 application 进行重命名, 你可能还要打开 index.php 文件,对变量 $application_folder 也要进行更改:

$application_folder = "application";

更改你的应用程序的文件夹路径

你可以将 application文件夹从system 文件夹中挪放到服务器的其他的位置。但是你还要更改 index.php 文件里将$application_folder变量设置为服务器的全路径

$application_folder = "/Path/to/your/application";

在一个 CodeIgniter 下运行多个应用程序

如果你想要多个应用程序共享同一个 CodeIgniter, 你要将 application 下所有的文件夹放在不同的应用程序的文件夹内。

例如,你要建立两个应用程序 "foo" 和 "bar",你的应用程序文件夹的结构可能会像下面的这样:

system/application/foo/
system/application/foo/config/
system/application/foo/controllers/
system/application/foo/errors/
system/application/foo/libraries/
system/application/foo/models/
system/application/foo/views/
system/application/bar/
system/application/bar/config/
system/application/bar/controllers/
system/application/bar/errors/
system/application/bar/libraries/
system/application/bar/models/
system/application/bar/views/

要选择使用某个应用程序,你需要打开主 index.php 文件,并且设置 $application_folder 变量为目标路径。例如,通过如下设置,就可以选择使用 "foo" 应用程序:

$application_folder = "application/foo";

注意: 每一个应用程序都会需要它自己的index.php文件来调用他的目标程序。你可以随意对 index.php 文件进行命名。

http://codeigniter.org.cn/user_guide/general/managing_apps.html

标签: ,

星期一, 四月 28, 2008

什么是 Kohana? Kohana 与 CodeIgniter 的区别?

作者:沧蓝 / Fred Wu

Kohana 是一款基于 CodeIgniter 的 PHP5 框架,其与 CI 最大的区别便是 Kohana 完全采用 PHP5。

2007 年 6 月 1 日,CI 社区用户 Todd Wilson (Tido) 发布了 BlueFlame 1.0 的帖子。BlueFlame 1.0 正式发布,团队成员有九人,其中包括 Todd(原团队 lead developer)、现在 Kohana 的 lead developer、以及本人。该发布贴引起了 CI 社区用户的广泛关注。然而由于 BlueFlame 团队事前没有与 CodeIgniter 团队进行沟通,导致一些理解上的小插曲,包括 Rick (CI 的祖父)要求 BlueFlame 团队停止使用 CI 的社区资源来发布 BlueFlame 相关的信息,以及对 BlueFlame 源代码中的授权部分表示疑义。

最终通过 BlueFlame 与 CodeIgniter 团队的协调沟通,双方的小小误解很快便被解化。Rick 在此期间提到 BlueFlame 名称的潜在版权问题,于是 BlueFlame 几天后便正式更名为 Kohana,并注册了现在的官方网站:kohanaphp.com

在 BlueFlame 1.0 之后,Kohana 团队一直没有发布新的版本,之后整个项目一度处于僵化期。尽管如此,trac 上还是有更新进度。在 Todd Wilson “消失”了一阵子后,成员之一 Woody Gilk (Shadow Hand) 接下重任,担当团队 leader。

之后 Woody 联络本人,希望本人承担 Kohana 官方网站以及 logo 的设计制作。论坛上仍然可以找到当时我发的帖子(内有网站以及 logo 的草案)。可惜由于时间的因素,我最终没有将设计草案转化为 HTML。可喜的是,Geert De Deckere 之后设计了一个相当出色的方案,这也就是大家现在所见到的 Kohana 的官方网站。 :)

2007 年 11 月,经过了团队成员以及社区用户的努力,Kohana 终于发布了 2.0 版本。

下面我来翻译一下 Wikipedia 对于 Kohana 的介绍。

历史

Kohana 是基于 CodeIgniter PHP 框架开发的。

开发 Kohana 最主要的原因是 CI 对于 bug 的修复和处理用户提交的建议所需的时间过长。许多 bug 在用户报告后很久才会纳入到新版本中,甚至一些 bug 一直没有被纳入。另外,由于 EllisLab 是 CodeIgniter 唯一开发者,部分用户对于框架的开放性产生异议,他们希望框架可以更自由开放,从而使社区对框架的发展产生一定的影响。

Kohana 与 CodeIgniter 的区别


  • 严谨的 PHP5 面向对象编程。优势:可见性保护、自动类装载、超载、接口类、抽象类以及单件类。
  • 延续 CodeIgniter 的设计模式。CodeIgniter 的用户能迅速的理解 Kohana 的架构和设计模式。
  • 社区向,而非商业向。Kohana 是一款基于社区的作品。Kohana 的开发者们来自世界各地,有着各自的天赋。这使得开发速度得以提高,并在短时间内提供bug修复以及反馈用户提出的建议。
  • GET、POST、COOKIE 以及 SESSION 数组得到改进。Kohana 不对全局数据做读取限制,但依旧提供与 CodeIgniter 相同的数据过滤以及 XSS 防护。
  • 层叠式资源、模块以及类继承。控制器、数据模型、库、助手以及视图均能够在系统中的任何地方进行载入。程序的配置选项可被继承或覆盖。
  • 无命名空间的冲突。类均添加了如“_Controller”之类的后缀,从而使得用户的控制器和数据模型可被同时同地装载。
  • 真正的自动类装载。这包括库、控制器、数据模型以及助手。与 CodeIgniter 不同,Kohana 的自动装载是真正意义上的动态装载,而并非预先装载。
  • 助手为静态类,而非函数。例如,在 CI 中使用的 form_open(),在 Kohana 中为 form::open()。
  • 库驱动以及 API 的一致性。库能够使用不同的驱动来处理不同的外部 API。例如,session 的储存有数据库、cookie 和 native 几种,但它们均使用相同的接口。这使得库可以不断的添加新的驱动,但不会影响到 API 的一致性。
  • 强大的事件处理器。Kohana 的事件可被动态的添加、替换或删除。这使得用户能在 Kohana 执行的过程中动态做更改,而不影响原有的系统代码。


特性


  • 高安全性
  • 轻量级代码
  • 学习周期短
  • MVC 设计模式
  • 100% UTF-8 兼容
  • 松弛耦合架构
  • 易扩展性


技术


  • 严谨的 PHP5 面向对象编程
  • 用 SQL 助手实现简单的数据库抽象层
  • 多 session 驱动(native、数据库、cookie)
  • 动态事件处理器


==============================

最后更新:2007 年 12 月 03 日

http://codeigniter.org.cn/forums/thread-91-1-1.html

标签: , , , , , ,

Notes on Choosing a PHP Framework: A Quick Comparison of CodeIgniter and Kohana

When I was reading through my subscribed feeds I came across this post: Notes on Choosing a PHP Framework: A Comparison of CakePHP and the Zend Framework by Chad Kieffer.

Chad has done a great job comparing the two frameworks that he’s interested in. That inspired me to write something up for the frameworks that I prefer and use. :)

I began hunting for PHP frameworks ever since Ruby on Rails hit the street. Coincidentally one of the first PHP frameworks I played with was CakePHP. At that time CakePHP’s documentation was nearly non-existent so I had to seek for an alternative. I did a lot of searches, and researches, and finally I was happy to see CodeIgniter. Its user guide was what impressed me the most, I am sure many of the fellow CI users would agree with me on this one. Because of the excellent documentation, I was able to start working on projects right after I spent a few hours on the user guide! Developing apps on CI was such a breeze! Today, I develop web applications in CodeIgniter, Kohana and Zend Framework. If you want to find out how to use Zend Framework components with CI or Kohana, please read my previous blog entry: Using Zend Framework with CodeIgniter.

From version 1.2 when I first started coding on CI, to the newly released version 1.6.1 it sure is a long way. CodeIgniter has progressed well and gained many web developers’ trust, despite a few glitches. One of which was the spawn of the fork: Kohana.

CodeIgniter had some low periods where developers were all focused on pushing out new releases of ExpressionEngine, their commercial blogging/cms product. Some of the users on the CI forum got frustrated because their bug reports and feature requests were ignored. As a result of that, BlueFlame was born, and later renamed to Kohana.

Kohana is relatively unknown to the public. In fact, most of the Kohana users are ex-CI users or users that uses both CI and Kohana (like myself). According to the Kohana homepage and Wikipedia, the differences between Kohana and CodeIgniter are:

  1. Strict PHP5 OOP. Offers many benefits: visibility protection, automatic class loading, overloading, interfaces, abstracts, and singletons.
  2. Kohana has joined the GoPHP5 initiative. All releases from 2.2 on will conform with this project.
  3. Continues CodeIgniter design patterns. Anyone who has used CodeIgniter will quickly understand Kohana’s structure and design patterns.
  4. Community, not company, driven. Kohana is driven by community discussion, ideas, and code. Kohana developers are from all around the world, each with their own talents. This allows a rapid and flexible development cycle that can respond to bugs and requests within hours, instead of days or months.
  5. GET, POST, COOKIE, and SESSION arrays all work as expected. Kohana does not limit your access to global data, but offers the same filtering and XSS protection that CodeIgniter does.
  6. Cascading resources, modules, and inheritance. Controllers, models, libraries, helpers, and views can be loaded from any location within your system, application, or module paths. Configuration options are inherited and can by dynamically overwritten by each application.
  7. No namespace conflicts. Class suffixes, like _Controller, are used to prevent namespace conflicts. This allows a User’s controller and Users model to both be loaded at the same time.
  8. True auto-loading of classes. This includes libraries, controllers, models, and helpers. This is not pre-loading, but true dynamic loading of classes, as they are requested.
  9. Helpers are static classes, not functions. For example, instead of using form_open(), you would use form::open().
  10. Library drivers and API consistency. Libraries can use different “drivers” to handle different external APIs transparently. For example, multiple session storage options are available (database, cookie, and native), but the same interface is used for all of them. This allows new drivers to be developed for existing libraries, which keeps the API consistent and transparent.
  11. Powerful event handler. Kohana events can by dynamically added to, replaced, or even removed completely. This allows many changes to Kohana execution process, without modification to existing system code.

As you can see, whilst maintaining a certain level of similarity to CodeIgniter, Kohana does offer some advantages (at the same time, some disadvantages). Let’s take a look at a few quick comparisons. Grading scale: Limited <>

Feature Comparison of CodeIgniter and Kohana
Feature CodeIgniter 1.6.1 Kohana 2.1.1 Notes
License Apache/BSD-style new BSD Licenses are similar, although Kohana uses the new BSD license which is slightly more flexible than CI’s modified BSD license.
PHP compatibility 4.3.2+ and 5 5.1.3+ CodeIgniter supports PHP4 whilst Kohana is a stict PHP5 framework. If you are using PHP5 then Kohana offers more OOP and performance advantages. Start from version 2.2 (yet to be released), Kohana will only support PHP 5.2+.
Supported Databases MySQL (4.1+)
MySQLi
MS SQL
PostgreSQL
SQLite
Oracle
ODBC
MySQL
PostgreSQL
SQLite
CodeIgniter’s longer history ensures us a more widely available database support options than Kohana, although in the future Kohana is likely to support more databases too.
Community Forum
Wiki
Bug Tracker
Forum
Trac
IRC
CodeIgniter obviously has a much larger community and offers a wiki for community members to share tutorials and code snippets. Kohana on the other hand, has a smaller community, however the developers are actively online on the forum and IRC.
Documentation / User Guide Excellent Limited CodeIgniter is known for its excellent user guide. Kohana is in the process of improving its documentation.
Tutorial / Sample Availability Good Fair Tutorials are available on both of their forums. CodeIgniter has the advantage of having a wiki for easier navigation. Kohana on the other hand, has a dedicated tutorial page for some of the tutorials.
MVC Strict Strict Both frameworks use the same MVC approach.
Modular / HMVC Via 3rd party libraries Built in Kohana is built with HMVC in mind whilst CodeIgniter has some 3rd party libraries such as Matchbox and Modular HMVC to accomplish the same effect.
Conventions Flexible Flexible Unlike CakePHP, both of the frameworks offer flexible convensions. There are some defaults but most of them can be overwritten.
Configuration PHP files PHP files In my opinion Kohana is more configurable than CodeIgniter yet it is simpler (less clustered) to do so! Most of the Kohana configuration files are stored in the system folder, you only copy and paste the ones you actually need to modify, and modify them accordingly. CodeIgniter’s config files are all stored in the application folder.
Database Abstraction Modified ActiveRecord Modified ActiveRecord
ORM (optional)
Both frameworks use the modified ActiveRecord pattern. Kohana has an optional ORM module. CodeIgniter has some ORM and Rails-style ActiveRecord implementation avaliable via 3rd party libraries.
ACL Via 3rd party libraries Auth library (optional) Neither of the frameworks forces you to use a specific ACL mechanism. CodeIgniter does not have one built in, and Kohana has one available as an optional module.
Validation Good Good Both frameworks offer a good built in validtion layer. Kohana 2.2 is planned to have some significant improvements for the validation library.
Caching Limited Fair In my opinion both of the caching features are limited. Kohana offers a slightly more useful cache library that supports file, SQLite, APC, eAccelerator, memcache, and Xcache based caching, with tag support.
Session Good Excellent CodeIgniter 1.6 has improved its session library, but it’s still inferior to Kohana’s implementation. Kohana’s session library supports both encryption and storing session data in database.
Logging / Debugging Good Excellent Both frameworks offer very good logging and debugging mechanisms. Kohana is a little bit ahead thanks to PHP5’s native Exception class and its powerful event handlers.
Templating Native PHP Native PHP Templating is *very* easy for both frameworks. If you can skin Wordpress, then you’d have no problems at all skinning CI or Kohana. If you want though, you can still incorporate one of the 3rd party templating solutions such as Smarty.
Helpers Good Good Helpers are usually libraries that used for simple, repetitive tasks. Both frameworks offer a wide range of helpers for handling forms, URLs and dates, etc.
JavaScript / AJAX N/A N/A Both frameworks respect your choice of JavaScript / AJAX frameworks. Unlike CakePHP and Ruby on Rails, they don’t have built-in helpers for any of the JavaScript libraries. This offers more flexibility as well as the use of unobtrusive JavaScript.
Web Services Fair Fair I could be wrong but I don’t think either framework supports (or at least encourages) RESTful design…
Localization Limited Good CodeIgniter has limited i18n support whilst Kohana offers a bit more (timezone / full UTF8 layer, etc).
Unit Testing Limited None * CodeIgniter’s built in unit testing class is very limited. * Kohana as of version 2.1.1 does not have a unit testing class, however it is planned for version 2.2.

The Verdict

I had a hard time deciding which of these two I use. In the end, I chose to use both. Why? Because they each have its advantages and disadvantages.

CodeIgniter is great for small to medium sized projects, especially good for legacy servers which have PHP4 installed. The fantastic user guide made coding in CI very efficient.

Kohana is probably better for larger sized projects as well as projects that need more flexible extensions. PHP5 offers better (proper) OOP support as the foundation, plus Kohana’s several better feature implementation make it a strong competitor to its predecessor.

There is no right or wrong for which framework you use, everyone has its own taste. For me, CodeIgniter’s excellent documentation and Kohana’s strict PHP5 + easy to use are the primary reasons to choose them over say, CakePHP and Symfony. That said, CakePHP, Symfony and other frameworks are all excellent choices depending on your taste and experience. On one hand I envy the Ruby community because they obviously have the de facto framework to work with, on another hand, we have more options hey? :)

Feel free to share your opinion and experiences!

Update log:

[2008-02-23]
- Removed MS SQL support for Kohana (confirmed by Shadowhand)
- Updated cache driver description for Kohana (confirmed by Shadowhand)
- Edited unicode / UTF8 description for Kohana (confirmed by Shadowhand)

These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • DZone
  • Furl
  • Live
  • Reddit
  • Slashdot
  • Spurl
  • StumbleUpon
  • Technorati
  • YahooMyWeb

标签: , , ,

星期一, 四月 21, 2008

PHP生成GUID

php下生成guid要用到class .
guid.class.php文件代码如下:

Name = $_ENV["COMPUTERNAME"];
$address->IP = $_SERVER["SERVER_ADDR"];
return $address;
}
function toString()
{
return strtolower($this->Name.'/'.$this->IP);
}
}
class Random
{
function nextLong()
{
$tmp = rand(0,1)?'-':'';
return $tmp.rand(1000, 9999).rand(1000, 9999).rand(1000, 9999).rand(100, 999).rand(100, 999);
}
}
// 三段
// 一段是微秒 一段是地址 一段是随机数
class Guid
{
var $valueBeforeMD5;
var $valueAfterMD5;
function Guid()
{
$this->getGuid();
}
//
function getGuid()
{
$address = NetAddress::getLocalHost();
$this->valueBeforeMD5 = $address->toString().':'.System::currentTimeMillis().':'.Random::nextLong();
$this->valueAfterMD5 = md5($this->valueBeforeMD5);
}
function newGuid()
{
$Guid = new Guid();
return $Guid;
}
function toString()
{
$raw = strtoupper($this->valueAfterMD5);
return substr($raw,0,8).'-'.substr($raw,8,4).'-'.substr($raw,12,4).'-'.substr($raw,16,4).'-'.substr($raw,20);
}
}
?>

guid.php文件
toString();
?>

http://blog.csdn.net/leon_founder/archive/2006/08/01/1006654.aspx

标签:

星期六, 四月 19, 2008

多年前的TIP,网站1变n

$site_matrix = array(
"$site1" => "$path1",
"$site2" => "$path2"
);

$def_pg = "$def_path";
$server = $_SERVER["HTTP_HOST"];
$pg = $site_matrix[$server];
if($pg == "") $pg = $def_pg;
header("Location: $pg");

这样你在一个虚拟主机上就可以同时使用两个域名了.

现在居然需要搜索。

标签:

星期四, 四月 17, 2008

About Project Zero

Project Zero began life as an incubator project to explore a new idea that we believed had promise. That idea was of a development and runtime environment that could revolutionize creation of dynamic web applications -- providing a powerful development and execution platform for modern Web applications while at the same time having the overall experience of being radically simple. We started this incubator because we wanted to address the complexities of modern Web applications without the chains of previous architectures, technologies, or decisions.

http://www.projectzero.org/

标签: ,

星期四, 四月 10, 2008

使用 PHP 创建图形的巧妙方法

Jack Herrington (jack_d_herrington@codegeneration.net), 高级软件工程师, "Code Generation Network"

2006 年 1 月 04 日

本文将展示如何使用 PHP 构建面向对象的图形层。使用面向对象的系统可以用来构建复杂的图形,这比使用标准 PHP 库中所提供的基本功能来构建图形简单很多。

我将图形编辑程序分为两类:一类是绘图程序,利用这种程序可以一个像素一个像素地绘制图像;另外一类是制图程序,这种程序提供了一组对象,例如线、 椭圆和矩形,您可以使用这些对象来组合成一幅大图像,例如 JPEG。绘图程序非常适合进行像素级的控制。但是对于业务图形来说,制图程序是比较好的方式,因为大部分图形都是由矩形、线和椭圆组成的。

PHP 内置的制图基本操作与绘图程序非常类似。它们对于绘制图像来说功能非常强大;但是如果您希望自己的图像是一组对象集合时,这就不太适合了。本文将向您展示如何在 PHP 图形库的基础上构建一个面向对象的图形库。您将使用 PHP V5 中提供的面向对象的扩展。

具有面向对象的图形支持之后,您的图形代码就非常容易理解和维护了。您可能还需要从一种单一的图形源将图形合成为多种类型的媒介:Flash 电影、SVG 等等。

More detail: http://www.ibm.com/developerworks/cn/opensource/os-objorient/

标签: ,

星期三, 四月 09, 2008

phpMyVisites

phpMyVisites是一个网站流量统计系统,它能够提供非常详细的统计报告和高级图形报表。phpMyVisites不是一个Apache log分析工具,它建有自己的log。它的特点包括:
  • 安装部署:提供可视化的安装向导,并且使用简单只要把一段简单的Javascript代码添加到你网站的页面中就能够马上开始收集访问者的信息。
  • 一个简洁,友好的界面可用来展示数据和帮助数据分析。
  • 提供简洁,明了的图形分析报表。
  • 安全:phpMyVisites能够最大限度地阻止入侵和外部攻击。
  • 支持多网站统计
  • 多用户:可以添加无限个用户并对每个用户赋予不同的管理权限(针对某一个网站的查看和管理的权限)。
  • 国际化支持:phpMyVisites提供30种语言包。
  • 能够准确统计一段时间内的访问量(天/周/月/年)。
  • 访问者的回头率:新访问者,经常访问者,有规律性的访问者。
  • 提供多种文件格式的统计报告(PDF,Image等)。
  • 对被统计的网页进行分组/分级。
  • 访问者分析:统计访问者是从哪个页面离开网站的和从哪个页面进入网站或通过哪个搜索引擎的关健字进入网站,在网站的停留时间,所访问的页面等。
  • 可通过e-mail或RSS聚合获取网站的流量信息。
http://www.phpmyvisites.net/

标签: ,

星期二, 四月 08, 2008

aSSL PHP library for SSL

aSSL is a library distributed under MIT License thats implements a technology similar to SSL without HTTPS.

aSSL enables the client to negotiate a secret random 128-bit key with the server using the RSA algorithm. Once the connection has been established, the data will be sent and received using AES algorithm.

aSSL is composed of some Javascript files and a server side component. Because I have recently changed the negotiation algoritm from RC4 to RSA, only a pure Javascript (ASP) server component is currently available. I will do a porting for the main web languages (PHP, Java, Perl, Python, TKL, etc.) as soon as possible once the library has passed the beta phase.

http://assl.sullof.com/assl/

标签:

星期五, 二月 22, 2008

Excel File Format Documentation

Excel File Format Documentation

  1. Microsoft Documentation
    • Download the Escher File Format Documentation
    • Read the Escher File Format Documentation online (this document is very very large!)
    • Pocket Excel File Format
    • Q147732 Records needed to make a BIFF 5 file excel can use
    • Q147942 DOCERR: Microsoft Excel Internal format table doc has errors
    • Q284441 DOC: Excel BIFF8 FORMAT Record Documentation Is Incomplete
    • Q284436 DOC: Excel BIFF8 Extended Rich String Formatting Run Is 4 Bytes
    • Q269168 HOWTO: Distinguish Between Excel 97 and Excel 2000/2002 Files
    • Q207475 DOC: Excel BIFF8 CONTINUE Record Information Is Incomplete
    • Q195237 LABEL Doc Error in MS Excel 97 Developer's Kit
    • Q184647 Xl97: BIFF Records Documentation Error in MS Excel 97 Developer's Kit
  2. 3rd Party Documentation

Source Code to deal with the Excel File Format

No matter what programming language you use, there is something here for you.
  1. For C programmers:
    • xlhtml - A c program for reading excel files.
    • xlreader Another c program for reading excel files
  2. For Java Programmers:
    • ExcelRead A java program for reading excel files
    • POI A java project to read and write Excel and OLE files
    • A java program to read and write the Pocket Excel file format.
  3. For Perl Programmers:
  4. For other languages:
http://chicago.sourceforge.net/devel/docs/excel/

标签: , , ,

星期日, 七月 22, 2007

php + clucene extension的安装

CLuceneSF上面的一个对Lucene(一个用Java写的全文检索引擎工具包)的移植,做为Lucene的C++的重新实现,以带来更快的检索速度,但是一直还不stable.这里仅仅是尝试php+clucene扩展的安装,具体应用先不管.

安装环境:
Freebsd 6.0 + apache 2.2 + php 5.1.2

apache+php的安装就不说了,网上一抓一大把,注意clucene扩展必须在php5以上才能安装.

  • 首先安装clucene

1.下载clucene
直奔它的首页–clucene.sourceforge.net,下载clucene 0.9.10
2.编译clucene

tar xzvf clucene-0.9.10.tar.gz
cd clucene-0.9.10
./autogen.sh
./configure
make

这样clucene就安装好了,为了让其它程序可以调用clucene,这里把编译好的lib放到系统lib目录下

cp src/.libs/libclucene.* /usr/local/lib
cp src/CLucene.h /usr/local/include/
cp -r src/CLucene /usr/local/include/

  • 安装clucene php extension

1.下载clucene php extension
在pecl.php.net有下载,拖回来就是
http://pecl.php.net/package/clucene

2.编译clucene php extension

tar xzvf clucene-0.0.9.tgz
cd clucene-0.0.9
cp -r /usr/local/include/Clucene include/ #编译时要把clucene的include文件弄一份
cp -r /usr/local/include/Clucene.h include/
phpize
./configure
make

编译完成,这里会生成一个clucene.so,我们把它放在php的extension目录下(没有就建一个),然后修改php.ini

加入
extension=clucene.so

重启apache之后看phpinfo

php+clucene

至此安装就算完成了,demo嘛在examples目录下有一个,命令行调用方式(根据已有的index检索):
php clucene.php “Your query”

BTW:新出的zend framework也有lucene模块,但是功能还不完善,现在0.1.2好像只能建立索引,检索功能尚在开发中

作者: volcano 发表于3月 22, 2006 at 2:28 pm

版权信息: 可以任意转载, 转载时请务必以超链接形式标明文章原始出处作者信息及此声明

标签: , , ,

星期四, 七月 05, 2007

NuSOAP调用.net的WebService

$client = new soapclient('http://localhost/TestService/Service1.asmx?WSDL', true);
//中间加入以下两行即可
$client->soap_defencoding = 'UTF-8';
$client
->decode_utf8 = false;

标签: , ,

星期四, 六月 21, 2007

Ubuntu安装PDO

pdo在ubuntu的apt里头似乎还找不到安装源,所以通过pecl来安装这个扩展,非常简单 —- 如果海底光纤能连通的话:

pecl install pdo

增加一行:

extension=pdo.so

到文件:

/etc/php/apache2/php.ini
/etc/php/cli/php.ini

接下来安装pdo_mysql碰到一些问题, 直接跑pecl install pecl_mysql会出现一些错误,搜索了一下发现是pecl本身的问题,下面是个比较简单的解决办法:

wget http://pecl.php.net/get/PDO_MYSQL-1.0.2.tgz
tar xzvf PDO_MYSQL-1.0.2.tgz
cd PDO_MYSQL-1.0.2

注释掉configure里头判断是否已经安装pdo扩展的代码片段,继续跑:

phpize
./configure
make
make install

然后再次添加下面一行到前面提到的两个php.ini

extension=pdo_mysql.so

重启apache之后, php5 + pdo_mysql就在ubuntu上安装好了, documentroot是/var/www

后记
更简单的解决办法是运行:

PHP_PDO_SHARED=1 pecl install pdo_mysql

标签: , ,

Prado国际出名的PHP框架

PRADO是一个基于组件和事件驱动的PHP5开发框架。它以组件,事件,属性来代替传统web开发中的程序,URLs和查询参数。一个 PRADO组件是由一个说明文件(XML),一个HTML模板和一个PHP类组件。一个个PRADO组件组合在一起形成大型组件或完整的PRADO页面。 PRADO具有如下特点:

复用性 - 符合PRADO组件标准的代码是高度可重用的。
易于使用 - 使用PRADO组件非常简单,通常只需要配置它们的属性,编写相关的事件处理函数。 健壮性 - PRADO让开发者不再被那些令人厌烦的有很多错误的的代码所困扰。它的代码都是有对象,方法和属性组成的;而不是Url地址和各种query参数。PHP5最新的Exception处理机制也被引入进来,让开发人员能够精确定位到错误代码的所在行数。
高效 - PRADO开发的Web应用运行很快。PRADO实现了一种缓存机制,使用其开发的应用的运行效率能够和那些通常使用的模版引擎开发的应用的运行效率相媲美。
团队开发 - PRADO允许内容和表现方式分离。组件,尤其是页面,将内容(逻辑)和表现方式分别保存在不同的文件中

http://www.xisc.com/

标签: , , ,

辽ICP备05003652号
流风洄雪听天籁,轻云蔽日看落花

Powered by Blogger