PHP ctemplate engine Development related content _php template

Source: Internet
Author: User
Tags php code php source code win32
1. Introduction

You may not be able to ctemplate PHP, the solution to see this noun, only know that its first half is a programming language. It's all right. Let me introduce you to this PHP-based label template engine (allow me to translate this web development solution, although I may not translate it correctly).

Let's talk briefly about his history. Understand the PHP ctemplate first to know Ctempalte;ctempalte full name is Google Ctemplate. It is a simple but highly efficient web template engine with C + + language. Let's take a look at a piece of code, smart you immediately know how it is used (from the official demo)

then the C + + output is:
Hello John Smith
You Have just won (here is the execution random%100000 random number)
Well, (here is the execution random %100000 random number again * 0.83), after taxes
Well, to sum up is the template object in C + + source load TPL (we can call it a template) file, and then populate the corresponding values in the Templatedictionary, Final output. That sounds awkward, right? The back-end tag values are populated with the corresponding value of the backend label in the {{tag}} of the TPL.
See http://google-ctemplate.googlecode.com/svn/trunk/doc/index.html
in more detail what about PHP ctemplate? We all know that PHP expansion bar, the friends who have played PHP know gd,exif,mysql,mysqli these extensions bar. Yes, that's the DLL in the php.ini file, "extension=." I summarize php ctemplate is using PHP to expand the interface format, packaging the Google Ctemplate, so that PHP has Google ctemplate functions. Again the popular point embodied in the code is: TPL file unchanged, just the C + + file into a php file. As for its usage I think I will not be introduced here, he and Google Ctempalte the same.
See http://code.google.com/p/php-ctemplate/
2.win32 OK
Maybe you'll soon realize that this template engine fits our common MVC bar. Yes, that's it. But unfortunately, PHP Ctemplate can only run in the FreeBSD system, Win32 Environment of PHP, I have not found the corresponding PHP ctemplate DLL, I also consulted the author of Php ctemplate, He seems reluctant to compile the code in a Win32 environment; I have and I developed C + + friend "Ah-hang" try to compile, we find the PHP source code + ctemplate source +php ctemplate Source code compiled Win32 under the PHP ctemplate extension, But it's strange that every time PHP starts loading php ctemplate, the PHP engine is abnormal and the PHP ctemplate doesn't load properly.

If the PHP ctemplate is loaded successfully, it will be displayed in Phpinfo:

I also looked at the PHP ctemplate source code seems to be based on Zend written. Because I am not very proficient in C + + and PHP, I really do not have the ability to rewrite this set of extensions, so can only think of a compromise approach: the Ctemplate with ATL COM Packaging, simulation of PHP ctemplate functions and methods.

3. My attempt

The reason is so tortuous, because with this frame, there is no way to debug the PHP code, I tried in the FreeBSD environment to install XDEBUG, well, can barely remote debugging. But FreeBSD is not a graphical interface, ah, but the installation of GNOME, only temporarily. Out of curiosity and uncertainty, I wrapped the ctemplate in ATL COM to simulate the functions and methods of PHP ctemplate, but it was only half done. In particular, I would like to thank "Ah-hang" comrade, without him I can not write the C + + ATL. The following are the methods in ATL COM (only partially completed).

I packaged the ATL COM features I packed in the core.php.

      If you are interested can find me to continue to improve the source code, because it is COM so ASP can also use, I will provide the DLL download. If the prawns are successfully compiled using PHP ctemplate under Win32, I would be more than welcome.
Download com file phpctempaltecom

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.