2016windows Wamp The simplest 30 minutes thrift get started using tutorials to implement PHP as a server and client of Hello World

Source: Internet
Author: User
Tags php write

2016 simplest windows (TEN) Wamp 30 minutes Thrift Get started using tutorials to implement PHP as a server and client of Hello World

What is the simplest explanation for thrift? Thrift is a framework that is used to help communicate between programming languages, exchanging information (which can be understood as a tool, or as a software artifact). Because of normal PHP and Java and other languages can not carry out data transmission, of course, usually we use the interface to pass Jeson data implementation. But the use of thrift will have its advantages, I see is that his data transmission method makes the data transmission is very small, this aspect can be self-search to understand. For example: Someone has written a Java program that can give some data, you are the PHP write site, you need this data, how do you get it? Because Java's data structures and types are different from PHP. So use thrift to achieve the intermediate conversion, the specific how to convert you do not care. Just like you use QQ, you just and good repair hair message chat is, QQ how to send how to receive you do not have to tube.

Specific implementation:

Note: The program code in this example refers to the code of the two blogs, so there are some things that are only required for this code and can be adjusted on their own. Also note: I see this on the official web.

Note: The installation of the thrift environment needs to download 2 things on the official website, one is the software. exe file, one is the language of the package--presumably for the software to implement the data transmission of the various languages of the specific implementation (but note: Windows will have a corresponding package to download, However, in the Linux environment, the installation process seems to implement the corresponding package deployment, no longer want to download and make the corresponding package selection and directory structure deployment of Windows, depending on other blogs.

    1. Download thrift. EXE software
    2. Download thrift for each language of the package (Action execution Search) as follows:
    3. Write a thrift file (through which you tell thrift what you're going to do, implement it automatically when generating code, that's what thrift does), and generate the corresponding code with the thrift. EXE, which is implemented by a command. It seems that the code does not have to be modified, and thrift seems to have implemented the specific process through the code. Each time the thrift structure is modified, it should be generated once.
    4. Client and server side (the simplest understanding: The server is your website or application, you need to get other people in Java and other languages written by the interface to provide data, the other side is the equivalent of the servers)
    5. Thrift the download of the various languages of the package in accordance with the specified format in the Site directory structure-refer to my: Thrift package structure, choose their own corresponding language package (I use PHP as a server, so the choice is PHP package):
    6. Thrift the directory structure naming requirements of the test project, note that when using the two blogs that I refer to, the Tagged folder name must be named this way (you can, of course, modify the corresponding directory in the program to adjust this):

More complex data structure definition, type and other self-reference examples to modify, refueling.

Implemented my own thrift output Hello World, out of the company's demo:

See the client and server code that borrowed the blog: http://my.oschina.net/penngo/blog/496992 Thrift file Code: http://my.oschina.net/penngo/blog/489311

2016windows Wamp The simplest 30 minutes thrift get started using tutorials to implement PHP as a server and client of Hello World

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.