使用THinkPHP框架开发程序,经常容易遗忘的事是什么呢?
1、app runtime没有及时更新
2、datamodel 缓存在更改表结构后没有刷新
3、数据缓存设定的时间太长。而在更改数据后没有主动刷新
4、模版缓存中的 include file 一般不会强制刷新。。
以上是开发注意事情,如果你发现改了一些设置或者其他什么后,死活不正常,请先检查以上四样。
Submitted by gouki on 2010, January 28, 3:01 PM
使用THinkPHP框架开发程序,经常容易遗忘的事是什么呢?
1、app runtime没有及时更新
2、datamodel 缓存在更改表结构后没有刷新
3、数据缓存设定的时间太长。而在更改数据后没有主动刷新
4、模版缓存中的 include file 一般不会强制刷新。。
以上是开发注意事情,如果你发现改了一些设置或者其他什么后,死活不正常,请先检查以上四样。
Submitted by gouki on 2009, December 29, 9:08 AM
这其实是一个老问题,凡是使用ThinkPHP与Ucenter通讯的程序都需要注意一点。。
ThinkPHP定义了一个基类为Base类,而Ucenter也同样定义了一个基类Base类。
ThinkPHP一开始就加载了BASE类,而Ucenter在使用mysql连接的的时候,就会加载BAse类。因此,凡是使用thinkphp的程序,请把ucenter的连接方式从mysql改为空,即,改用post方式通信 。
Over
其实,关于这个BUG,我很早就在discuz论坛提过了。当然也在ThinkPHP论坛提过。但事实上,都没有什么解决方案。而我更推崇的应该是ucenter进行变化。。呵呵
原文我发在了:UCAPI.COM,然后我再去挖挖坑,看看DZ和TP论坛以前是怎么回复的。。
原来,在DZ,根本就没有人理我:http://www.discuz.net/thread-1204869-1-1.html,这是当时说的两个BUG:
TP论坛我是在群里提的。。。没记录了。唉。。
Submitted by gouki on 2009, December 2, 9:36 PM
widget最早的应用应该是vista了。。但WEB上的就说不准谁是最早应用的。。。
ThinkPHP从很早的版本里就有支持了,但,我却一直没有用过,依稀记得yblog在用widget的时候,好象ThinkPHP那时候还没有正式支持。。
我这次使用,其实也算是个意外,在对thinksns二次开发的时候,有些页面需要经常重用,不得己,只能使用widget了。
随便看了一下,如果仅仅只是用来显示一些简单的页面,那么widget还是很方便的就能够被使用了。thinkphp2.0的手册中也有介绍。。
最简单的用法莫过于在Lib目录下,新建一个widget目录。然后放上一个class文件,最后附上一个基本同名的模版就行了。。
在正式的模版中使用【我是指使用TP的情况下】,直接{:W('RightSlide',array('data'=>1))}就可以了。
很简单吧。
Submitted by gouki on 2009, November 16, 4:24 PM
仍然是quickstart的内容之一:create project
In order to create your project, you must first install Zend Framework.
为了创建您的ZF项目,你必须先安装ZF框架
The easiest way to get Zend Framework along with a complete PHP stack is by installing Zend Server. Zend Server has native installers for Mac OSX, Windows, Fedora Core, and Ubuntu, as well as a universal installation package compatible with most Linux distributions.
最简单安装ZF的方法就是安装ZendServer,ZendServer可以安装在苹果系统,windows, fedora,ubuntu,而且支持大多数的linux操作系统 。
After you have installed Zend Server, the Framework files may be found under /Applications/ZendServer/share/ZendFramework
on Mac OSX, C:\Program Files\Zend\ZendServer\share\ZendFramework
on Windows, and /usr/local/zend/share/ZendFramework
on Linux. The include_path
will already be configured to include Zend Framework.
在你安装完zendserver后,如果您是使用MAC系统,你将在/Applications/ZendServer/share/ZendFramework目录下找到
框架文件,windows平台的话,是在, C:\Program Files\Zend\ZendServer\share\ZendFramework目录中,而linux平台则在
/usr/local/zend/share/ZendFramework目录中。同时include_path也已经被配置好支持ZF框架了。
Alternately, you can download the latest version of Zend Framework and extract the contents; make a note of where you have done so.
当然你也可以直接下载ZF的最新版本并解压到你想使用的目录中
Optionally, you can add the path to the library/ subdirectory of the archive to your php.ini's include_path setting.
或者,你也可以把library这个目录加载到你的php.ini中的include_path设置中。
That's it! Zend Framework is now installed and ready to use.
这时候,ZF框架就已经被安装好并能够被使用了。
Open a terminal (in Windows, Start -> Run, and then use "cmd"). Navigate to a directory where you would like to start a project. Then, use the path to the appropriate script, and execute one of the following:
打开终端(在windows下面为:开始->运行->输入cmd),转到你想要创建项目的子目录中,开始就可以开始使用你刚才设置的路径来运行那两个script之一了。
Running this command will create your basic site structure, including your initial controllers and views. The tree looks like the following:
运行了这个命令,你将会得到ZF框架的项目的最基本结构,包含了初始化后的控制和和视图(controllers and vews),这个树形结构类似如下:
At this point, if you haven't added Zend Framework to your include_path, we recommend either copying or symlinking it into your library/ directory. In either case, you'll want to either recursively copy or symlink the library/Zend/ directory of your Zend Framework installation into the library/ directory of your project. On unix-like systems, that would look like one of the following:
在这点中,如果你没有将ZF框架加入到你的 include_path ,我们推荐你将它 COPY或者 symlinking到你的 library目录下。两种方法其中都是将library/Zend 目录 链至你的项目。在unlx系统中,它大致是这样操作的:
On Windows systems, it may be easiest to do this from the Explorer.
在windows平台下,直接在资源管理器中就能够操作完毕。
Now that the project is created, the main artifacts to begin understanding are the bootstrap, configuration, action controllers, and views.
项目创建完毕后,the main artifact【不知道如何翻译】先了角解一下:bootstrap,configuration,action,controllers和views
Your Bootstrap class defines what resources and components to initialize. By default, Zend Framework's Front Controller is intialized, and it uses the application/controllers/ as the default directory in which to look for action controllers (more on that later). The class looks like the following:
Bootstrap类定义了资源和构成的初始化。默认情况下ZF只初始化了Front Controller【前端操作器】,它使用了 application/controllers 作为默认目录,在该目录里有着controller控制类的文件。bootstrap最初是这样的:
As you can see, not much is necessary to begin with.
就你看到的内容来说,好象没有多少是必需的。
While Zend Framework is itself configurationless, you often need to configure your application. The default configuration is placed in application/configs/application.ini, and contains some basic directives for setting your PHP environment (for instance, turning error reporting on and off), indicating the path to your bootstrap class (as well as its class name), and the path to your action controllers. It looks as follows:
ZF本身的配置是极少的,你通常需要为你自己的项目进行单独配置。默认的配置文件是/application/configs/application.ini,在文件中定义了一些PHP环境变量(如error_reporting的打开与否)和bootstrap类的路径(甚至是bootstrap类的名称),以前你的控制器的路径,内容如下:
关于这个文件的必须要注意一些事。首先,当你使用ini格式的配置文件时,你可以直接引用常量,如APPLICATION_PATH就是一个常量。另外,还有一些选择器是默认定义过的:production,staging,testing和defelopment。后面三个设置都是从production的环境变量中扩展的。这样,你就可以很好的为你的项目开发进行适当的配置。
原文:http://framework.zend.com/docs/quickstart/create-your-project
有点长,写的也乱。先写这么多,下次补全。
其实不太想翻译这个,毕竟太初级了。。。我想翻译的是这个:http://devzone.zend.com/tag/PHP101
但是翻译现在这个QuickStart是可以让我在言语组织上学习点东西。先为我想翻译的东西打点基础吧。
Submitted by gouki on 2009, November 13, 9:24 AM
最近重操旧业,看起了zend framework,如今的1.9x与以前不一样了。所以,把ZF的quick start逐步翻译一下,权当复习和温故了。
原文地址:http://framework.zend.com/docs/quickstart/create-a-model-and-database-table
Zend Framework is an open source, object oriented web application framework for PHP 5. ZF is often called a 'component library', because it has many loosely coupled components that you can use more or less independently. But Zend Framework also provides an advanced Model-View-Controller (MVC) implementation that can be used to establish a basic structure for your ZF applications. A full list of Zend Framework components along with short descriptions may be found in the components overview. This QuickStart will introduce you to some of ZF's most commonly used components, including Zend_Controller, Zend_Layout, Zend_Config, Zend_Db, Zend_Db_Table, Zend_Registry, along with a few view helpers.
Using these components, we will build a simple database-driven guest book application within minutes. The complete source code for this application is available in the following archives:
zend framework 介绍
ZF是一个开源且面向对象的,支持PHP5的WEB应用框架。ZF通常被叫做“组件库”,因为他拥有很多松耦合的组件,因此你可以在应用中或多或少的独立使用它们。但ZF更多的是为你的ZF应用提供了一个高级的MVC架构【??翻译不来了】所有的ZF组件列表,你可以从 组件预览 页进行查看。而这个QuickStart会给你的ZF最通常使用的组件进行介绍,如Zend_Controller,Zend_layout,Zend_Config,Zend_Db,Zend_Db_table,Zend_Registry,以及一些视图助手【这个应该是讲View的,但不知道怎么翻译好。现在终于明白那些翻译书的朋友们的痛苦之处了。明知道啥意思就是说不出口,还是词汇量少啊】
So what exactly is this MVC pattern everyone keeps talking about, and why should you care? MVC is much more than just a three-letter acronym (TLA) that you can whip out anytime you want to sound smart; it has become something of a standard in the design of modern web applications. And for good reason. Most web application code falls under one of the following three categories: presentation, business logic, and data access. The MVC pattern models this separation of concerns well. The end result is that your presentation code can be consolidated in one part of your application with your business logic in another and your data access code in yet another. Many developers have found this well-defined separation indispensable for keeping their code organized, especially when more than one developer is working on the same application.
MVC
那么我们就来讲讲什么是MVC了以及你对于MVC来说,最关心的是什么。MVC虽然只是三个单词的开始每个字母组成的新词,然而他已经成为了网页程序的标准设计模式了。而且,有充分的理由证明,大多数的网络程序代码都被归于以下三种分类之一:表达方式【?】,商业逻辑 和数据访问层。MVC模式则能够使你们将关注点进行分离。最终你的表示代码只占你的商业逻辑的一小部分,同样数据访问层也是这样。大多数开发人员发觉这能够使得他们保持代码分离并且条理清晰,尤其是在同一项目中有多名开发人员时。
翻译的很迷惘。。。
其实上面的大意无非就是MVC结构使得程序员可以将更多的精力放在业务逻辑上,而不是将大量的精力浪费在表现层和数据访问上。
不过,虽然翻译的很乱,但我还是多少又理解了一点这方面的知识。MVC如今已经被很多人所接受,很多招聘上也都写着,熟悉MVC模式开发。其实,如果真正项目已经按着MVC模式开发的话,那么招聘进去的人,又有多少是同时对于这三个方面进行开发的呢?
Model - View - Controller,在ZF框架中也是很分离的。看框架的 application目录就很清楚了。除了module和config目录外,剩下的就是:controllers,models和views目录了。。由此可见,基本上也分得比较清楚了