Java-based PHP framework

Source: Internet
Author: User
Tags connection pooling copy php framework web services tomcat apache tomcat

Brief introduction

Quercus is an open-source PHP 5 engine that already has a full implementation of pure Java. The Quercus document states that Quercus runs on top of the Resin application server, leveraging Resin features such as load balancing, proxy caching, and so on. This article describes the features that are provided by running Quercus on top of Apache Tomcat. In addition, this article will demonstrate the ease of use and flexibility of the Quercus "PHP + Java" hybrid approach for WEB services and applications.

Why Choose Quercus?

The Quercus PHP Library is fully implemented in Java, which is good for both Java and PHP applications. Because of the tight integration between Java and PHP, Quercus applications can use Java technology and frameworks such as Spring, Hibernate, and SOA. To facilitate this interoperability, Quercus provides an API to invoke the Java library from PHP.

Other benefits include:

Easy to develop: PHP libraries are implemented in Java, which makes them faster, more stable, and easier to use. Developers need not worry about the segmentation (segmentation) Errors and C-pointer overflows that occur in the C-language-based PHP implementation.

Scalability: As a java-based implementation, Quercus runs on application servers such as Resin and Apache Tomcat. In this way, it can take advantage of all the features provided by the application server, such as connection pooling, distributed sessions, and so on.

Internationalization: Because Quercus is a Java implementation of PHP, it supports 16-bit Unicode strings and functions in its own right.

Install Quercus

Installing Quercus is simple, installing a jar file into a Java application, but because Quercus is a feature of the Resin application server, it is also built in Resin. There is no need to download the PHP engine because Quercus can act as a PHP engine. Follow these steps to install Quercus:

Download the Resin application server from the corporate Web site.

Open this compressed file and extract the jar file: Quercus.jar, Resin-util.jar, and Javamail-141.jar.

Copy these files and the MySQL connector jar file (if necessary) to your WEB application's Webcontent\web-inf\lib folder.

Another simple installation method is to copy libraries from there based on the compression sample application provided at the end of this article.

Enter Quercus

To introduce the features of Quercus, I'll show you a simple HelloWorld example. This application can be created by using the following procedure. (All of the applications used in this article are created using the Eclipse IDE, and some steps also provide screenshots to make them more intuitive.) You can also select a different IDE.

The basic purpose of the following steps is to create a dynamic WEB application project that points to the application Server runtime (Apache Tomcat in this case) and configures parameters such as PHP.ini and Web.xml.

Create a new Web project in the IDE (in this case, Eclipse), as shown in Figure 1 (Alt + Shift + N).

Figure 1. Create a new project

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.