As the company needs it, our subsequent projects will adopt the PhpCtemplate engine for development. Here, I just wrote what I learned this month and my understanding. If there are any errors or inaccurate descriptions, I hope you can criticize and point out 1. Introduction
You may not be able to understand Php Ctemplate. the first half of Php Ctemplate is a programming language. It doesn't matter. let me introduce you to this php-based label template engine (please allow me to translate this web development solution, although I may not translate it accurately ).
Let's briefly talk about his history. To learn about Php Ctemplate, you must first know Ctempalte. The full name of Ctempalte is Google Ctemplate. It is a web template engine that uses the c ++ language and is simple but highly efficient. Let's look at a piece of code. if you are smart, you immediately know how to use it (from the official Demo)
Then the C ++ output is:
Hello John Smith
You Have just won (here is the random number of random % 100000 executed)
Well, (here is the random number of random % 100000 and then * 0.83), after taxes
Let's sum up: load the Template object in c ++ source code into the tpl (we can call it a Template) file, then fill in the corresponding values in the TemplateDictionary, and finally output the object. It sounds like an interface, right? simply add the corresponding value of the backend tag to the {tag} of the tpl.
For more information, see http://google-ctemplate.googlecode.com/svn/trunk/doc/index.html
What about PHP ctemplate? Everyone knows about PHP Extensions. anyone who has ever played with PHP knows about gd, exif, mysql, and mysqli extensions. Yes, it is the dll in "extension =" in the php. ini file. In my summary, PHP ctemplate is packaged with Google Ctemplate in the format of PHP extension interface, so that PHP has the function of Google Ctemplate. The common point is that the tpl file remains unchanged, but the c ++ file is changed to the PHP file. As for its usage, I don't want to introduce it here. it is the same as Google Ctempalte.
See http://code.google.com/p/php-ctemplate/
2. Can I use WIN32?
Maybe you will soon realize that this template engine conforms to our common MVC. That's right. But unfortunately, PHP Ctemplate can only be run in Freebsd. php in win32 environment has not found the corresponding PHP ctemplate dll on the Internet. I have consulted the author of PHP ctemplate, he seems unwilling to compile the code in the win32 environment; I tried to compile it with my friend "dumb" who developed c ++, we found the php source code + Ctemplate source code + PHP ctemplate source code to compile the PHP ctemplate extension under win32, but it is strange that every time php starts loading PHP ctemplate, an exception occurs in the php engine, and the PHP ctemplate cannot be loaded normally.
If php ctemplate is loaded successfully, it will be displayed in phpinfo:
I also read the PHP ctemplate source code, which seems to be written based on Zend. Because I am not very proficient in c ++ and php, and I am not capable of re-writing this extension, I have to think of a way to fold: wrap the Ctemplate with ATL COM, simulate PHP ctemplate functions and methods.
3.My attempt
The reason for this twists and turns is that after using this framework, there is no way to debug the PHP code. I tried to install xdebug in the freebsd environment. well, I can barely perform remote debugging. However, freebsd does not have a graphical interface. you have to install gnome. Out of curiosity and disappointment, I wrapped the Ctemplate in ATL COM to simulate PHP ctemplate functions and methods, but it was only half done. Here, I would like to express my special thanks to comrade "dumb". without him, I cannot write c ++'s ATL. The methods in atl com are as follows (only part of them are completed ).
I wrapped the ATL COM function in core. php.
If you are interested, contact me to continue to improve the source code, because it is COM, so ASP can also be used, and I will provide the dll for download. If the prawns successfully compile and use the PHP ctemplate under win32, I am not sure.
Download the COM file phpctempalteCOM