PHP Ctemplate Related content

Source: Internet
Author: User
Tags php source code
Because the company needs, the project behind us will be developed using the PHP ctemplate engine. Here, I am just the one months I learned, and my understanding of writing. If there is an incorrect, or inaccurate description of the place, I hope you can criticize the point.

1. Introduction

You may not be able to ctemplate PHP, you can see this noun, only know its first half is a programming language. No, 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 a little bit about his history. Learn PHP ctemplate first to know that Ctempalte;ctempalte full name is Google Ctemplate. It is a simple but highly efficient web template engine in C + + language. Let's look at a piece of code, and you'll know immediately how it's 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 random number of execution random%100000 and then * 0.83), after taxes

Well, summing up is the C + + source of the template object loading TPL (we can call it a template) file, then populate the corresponding value in the Templatedictionary, the final output. That sounds a bit awkward, isn't it? Simply fill in the back-end tag values into the TPL's {{tags}}.

For details, see http://google-ctemplate.googlecode.com/svn/trunk/doc/index.html

So what about PHP ctemplate? Everyone knows PHP extensions, and friends who have played PHP know gd,exif,mysql,mysqli these extensions. Yes, that's the DLL in the php.ini file "extension=". I summarize PHP ctemplate is to use PHP extension interface format, packaging Google Ctemplate, let PHP with Google ctemplate function. Again popular point in the code is: the TPL file is not changed, just the C + + file into a php file. As for its usage I don't think I've introduced much here, he's like Google Ctempalte.

See http://code.google.com/p/php-ctemplate/

Can you 2.win32?

Perhaps you will soon realize that this template engine conforms to our common MVC. Yes, that's it. But unfortunately, PHP ctemplate can only be run in the FreeBSD system, Win32 environment PHP, I have not found the corresponding PHP ctemplate DLL online, I also consulted the author of Php ctemplate, He seems reluctant to compile the code in the Win32 environment; I once and I developed C + + friends "ah-hang" try to compile, we find PHP source code + ctemplate source code +php ctemplate source code compiled Win32 PHP ctemplate extension, However, it is very strange that every time PHP starts loading php ctemplate, PHP engine will be abnormal, PHP ctemplate not load properly.

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

I also read the next PHP ctemplate source code seems to be based on Zend written. Because I am not very proficient in C + + and PHP, and really do not have the ability to rewrite the extension, so I 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 framework, there is no way to debug PHP code, I tried to install xdebug in the environment of FreeBSD, well, barely able to remote debugging. But FreeBSD is no graphical interface, ah, helpless under the installation of GNOME, only temporarily this. Out of curiosity and intolerance, I wrapped ctemplate in ATL COM, simulating PHP Ctemplate's functions and methods, but only half finished. In particular, I would like to thank the "ah-hang" comrade, I can not write the C + + ATL without him at all. Here is the method within ATL COM (only partially completed).

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

If everyone is interested can find me to continue to improve the source code, because it is COM so ASP can also use, I will put the DLL to provide download. If the prawns have been successfully compiled under Win32 using PHP ctemplate, I would prefer.

Download com

  • Related Article

    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.