GithubHelp home page GithubHelp logo

artem / kphp Goto Github PK

View Code? Open in Web Editor NEW

This project forked from vkcom/kphp

0.0 0.0 0.0 33.11 MB

KPHP — a PHP compiler

Home Page: https://vkcom.github.io/kphp/

License: GNU General Public License v3.0

Shell 0.01% C++ 68.28% Python 2.77% C 3.80% PHP 24.37% Hack 0.01% CMake 0.56% Yacc 0.14% Dockerfile 0.01% Ragel 0.06%

kphp's Introduction

macos debian ubuntu

KPHP — a PHP compiler

KPHP is a PHP compiler. It compiles a limited subset of PHP to a native binary running faster than PHP.

KPHP was developed at VK.com and maintained as proprietary for years — until open-sourced in late 2020.

Visit the KPHP website with documentation, demos, etc.

Limitations

KPHP wouldn't compile just any random PHP code:

  • It doesn't support features that can't be compiled, such as calling by name or mocks.
  • It won't compile code, that breaks the type system, for instance, mixing numbers and objects in an array.
  • It doesn't have PHP features that VK.com never had a need for, such as SPL classes and XML parsing.
  • Some PHP syntax details just weren't implemented, like generators and anonymous classes.

Read more on this here: KPHP vs PHP differences.

Features over PHP

KPHP analyzes your code as a whole and performs various optimizations focusing on performance and safety:

  • Inferring types of all variables, how to declare them in C++.
  • Compile-time optimizations, such as inlining getters or reducing refcounters flapping.
  • Compile-time checks, including immutability and type system requirements.
  • Runtime optimizations, like constant arrays pre-initing and typed vectors.

Aside from the above, KPHP has coroutines. For now, however, they are almost inapplicable outside of VK code.

Benchmarks

Generally, when your code fits best practices, it runs 3–10 times faster than PHP.

Take a look at the benchmarks page comparing KPHP and PHP performance.
You can also refer to PHP vs KPHP vs C++.

KPHP isn't always faster than PHP, but it can be used to speed up your code by focusing on strict typing and KPHP built-in functions.

"I tried to compile PHP code, but failed"

This situation is quite common. KPHP rarely compiles already existing code without errors. It usually takes some time to rewrite PHP code for it to be compilable with KPHP.

Read more about this in compiling an existing project.

The License

KPHP is distributed under the GPLv3 license, on behalf of VK.com (V Kontakte LLC).

Ask questions and provide feedback

To communicate with KPHP community, use Github issues or public E-Mails available on Github.

You can also take a look at our FAQ page.

Contributing

Please, refer to the Contributing page.

How do I start using KPHP?

Proceed to the installation page and just follow the left menu.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.