KPHP — a PHP compiler

KPHP basics

  • 1. Installation
  • 2. Compile a sample PHP script
  • 3. Quickstart a new project
  • 4. Compile your existing project
  • 5. Typical usage issues
  • 6. FAQ
  • 7. What's new?
  • 8. Roadmap

KPHP as a language

  • KPHP vs PHP
    • 1. KPHP vs PHP differences
    • 2. KPHP functions extending PHP
    • 3. Available PHPDoc annotations
    • 4. What exactly would be compiled?
    • 5. Compiler command-line options
    • 6. Benchmarks
  • PHP extensions for using KPHP
    • 1. PHP polyfills
    • 2. vkext
    • 3. PHP snippets
    • 4. FFI
  • Static typing and KPHP type system
    • 1. Type inferring
    • 2. PHPDoc to declare types
    • 3. KPHP type system
    • 4. Instances (objects)
    • 5. Typed arrays
    • 6. Casting types
    • 7. Generic functions f<T>()
    • 8. Generic classes C<T>
  • KPHPStorm — IDE plugin
  • Various “howto” solved by KPHP
    • 1. Call a function by name
    • 2. Serialization, msgpack
    • 4. JSON encode and decode
    • 4. PHPUnit, mocks, etc
    • 5. Exceptions
    • 6. Colored functions
    • 7. Compile-time location
  • Best practices and optimization
    • 1. Strict typing is performance
    • 2. Async programming: coroutines
    • 3. Parallelism: job workers
    • 4. Shared memory across requests
    • 5. Embedded profiler, like valgrind
    • 6. Performance inspections
    • 7. Examine codegenerated sources
    • 8. Compiling huge projects

KPHP as a client

  • TL schema and RPC calls
    • 1. TL schema basics
    • 2. Untyped RPC
    • 3. Typed RPC
    • 4. tl2php
  • Working with external DBs
    • 1. Invoking memcache(d)
    • 2. Invoking MySQL
    • 3. Invoking postgres / redis / etc
    • 4. gRPC, protobuf

KPHP as a server

  • KPHP architecture as backend
    • 1. KPHP is a web server
    • 2. nginx streaming to KPHP
    • 3. Combining KPHP and PHP code
  • Deploy and maintain
    • 1. Strip a binary before deploying
    • 2. Graceful restart
    • 3. Runtime metrics and statsd
    • 4. Logging
    • 5. Mapping C++ trace to PHP code
  • Execution options
    • 1. Server command-line options
    • 2. Microservices
    • 3. CLI mode

KPHP Internals

  • Implementation and architecture
    • 1. Compiler
    • 2. Runtime
    • 3. Server
    • 4. vkext
  • Developing and extending KPHP
    • 1. Compiling KPHP from sources
    • 2. Writing and running tests
    • 3. kphp-diff-comparator tool
    • 4. Contributing to KPHP
    • 5. KPHP rewrite rules
KPHP — a PHP compiler
  • KPHP basics

KPHP basics

These topics guide you through starting using KPHP.

  • Installation
  • Compile a sample PHP script
  • Quickstart a new project
  • Compile your existing project
  • Typical usage issues
  • FAQ
  • What's new?
  • Roadmap

Copyright 2025, LLC «V Kontakte»