Polarphp project introduction

Polarphp is a new PHP runtime environment, based on the latest Zend Virtual Machine, supports the latest language specifications, and provides its own runtime standard library (libPDk).

In short, PolarPHP is to PHP what NodeJS is to Javascript. NodeJS is built on top of the V8 engine and provides an environment for Javascript to run on the server. Polarphp is also built on the basis of Zend Engine to achieve a new operating environment in addition to Web development.

Project official website library:

Github.com/polarphp/po…

Gitee.com/polarphp/po…

Welcome to star ^ _ ^

Why launch polarPHP

PHP’s market share has been eroded by the rise of Go and NodeJS, while PHP officially remains firmly entrenched in Web programming, and some things get harder to hold on to. Polarphp uses NodeJS and Go for reference to repackage zendVM, remove some ancient abandoned PHP features and strong Web attributes, by implementing a new runtime framework libPDk, PHP language into a real universal scripting language, enabling PHP, so that it has asynchronous programming, coroutines, Threading, built-in Unicode support, standard file IO, and many other features allow PHP programmers to do not only web applications, but also real server applications.

Infrastructure provided by PolarPHP

  1. Direct to the terminal, remove SAPI to better realize the server environment.

  2. The canonicalization OPCODE forms a specification that provides a precompilation mechanism similar to pyC files.

  3. Provide native multithreading support, using Java programming paradigm in multithreading.

  4. Supports native asynchronous I/O.

  5. Provides Unicode support for strings.

  6. Provides a new way to organize packages with built-in package dependency management tools like Cargo and NPM.

  7. Provides built-in API document generation tools.

Overview of polarPHP architecture

The project is mainly composed of three parts, including the following three sub-modules

  1. polarvm

  2. zendAPI

  3. libpdk

The general relationship of this module is as follows:

polarvm <=> zendAPI <=> libpdk

Polarvm introduction

Zend Engine is a basic PHP implementation environment, such as:

  1. Language parsing, OPCODE execution.

  2. Implementation of the basic operating environment, variable operations, array operations, class loading mechanism, language reflection and so on.

  3. Zend engine initialization, language engine and terminal link, language engine to achieve direct control of standard input and output.

  4. Implement the callback mechanism between the language engine and the standard library.

ZendAPI introduction

Those of you who have done PHP extensions should know that when we were developing extensions, many of the zend Engine’s interfaces were provided in the form of macro calls, which were not safe in type, difficult to debug if errors were made, and some of the macros were very similar in length and cumbersome to manipulate arrays at the same time. The GC of Zend Engine is implemented by reference counting, and there is no linguistic mechanism to manage counting in C, so managing memory while writing extensions is tedious and can cause memory leaks. In particular, it can be a headache to use copy-on-write with references between PHP variables.

If our standard library is directly based on the native Zend Engine interface, it is bound to expand, maintainability will be seriously affected, especially the current polarVM is based on the secondary development of Zend Engine considerable circumstances. Therefore, a shielding layer is implemented between the language engine and the standard library, and a relatively stable and simple object-oriented CPP programming interface is provided on the top.

ZendAPI provides the following features:

  1. Fully object-oriented, redefining the Zend Engine API

  2. Developed using modern C++11 syntax for easy maintenance

  3. To maximize the impact of PHP versions on extension development, Zend API will eliminate differences between versions of the Zend Engine API

  4. High coverage of unit tests to ensure code quality

  5. When packaging, do your best to ensure performance

  6. Work on binary compatibility of the project library

Libpdk introduction

Libpdk is positioned as a standard library in the PolarPHP language. PDK stands for PHP Development Kit. In the design of the reference Java JDK module organization style, to provide PHP with a rigorous and powerful runtime standard library, so that the implementation of efficient server-side programming is possible, such as the use of PHP to achieve Netty like the event-driven network framework, or CoreDNS like the application project is possible. It also makes it easier to develop terminal applications like NPM, Cargo, PM2 and the like. In the Web domain, libPDk enables PolarPHP to listen to ports directly from SAPI like GO, which makes it easier to implement a lightweight service framework like GIN based on the event loop model and multi-threaded model.

Project library address: github.com/polarphp/li…

The following modules are planned for PDK

  • Base modules (basic modules that implement basic functions such as input/output, file systems, processes and threads, event models, etc.)

  • Network module (Network module, based on the basic module, to achieve a set of high-performance Network framework, so that the writing of the server system is more convenient)

  • Web Module (Web module that implements the common Http protocol and provides a Web runtime container of type Serlet)

  • GUI Module (user interface module, future implementation, enabling PHP to write common client system, based on openGL implementation)

Polarphp development plans

Due to limited development resources, the tentative development plan is as follows:

  1. Zend VM was compiled using Cmake to generate polarPHP custom VERSION of PHP language VIRTUAL machine.

  2. Language support project, language testing framework, LIT testing framework for porting LLVM project.

  3. Polarphp driver implementation from the command line to execute PHP code.

  4. Regression test was conducted on PolarPHP VIRTUAL machine, and regression test related to language virtual machine of PHP was temporarily decided.

  5. Implement polarPHP’s built-in functions.

  6. Publish the Docker image of the core VM.

  7. Integrate the libPDk runtime framework.

  8. Polarphp is installed in as few steps as possible.

  9. Implement the package manager.

  10. Implement language matching widgets, such as document generation tools, and so on.

Polarphp preferred supported operating systems

  • debain

  • centos

  • ubuntu

  • openSUSE

  • macOS

We plan to support Windows operating system natively in the future, and we are currently storing knowledge.

The current state of PolarPHP

At present, the project is in a very early stage, and the iterative release of the project is realized through docker image. At present, I mainly develop the project in my spare time, welcome everyone to play with me. An important task in 2019 is to improve the PolarPHP standard library libPDK and achieve stable operation on the mainstream Linux operating system.

How to participate in

At present, we only aim at Chinese users, so we use wechat and QQ group to communicate. The following is the qr code, students who are interested can scan the code to join :(wechat ^ _ ^ is recommended)

There are currently the following working groups

  1. Language Core Team

  2. Library team

  3. Ecological chain project team

  4. Document team

  5. Official website maintenance team

A link to the

  • Polarphp details: Click here to see
  • Polarphp download address: Click to download