• Stars
    star
    690
  • Rank 65,522 (Top 2 %)
  • Language
    PHP
  • License
    BSD 3-Clause "New...
  • Created about 6 years ago
  • Updated 11 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

PHP in Go

Goro

Build Status GoDoc Telegram

This is an implementation of PHP, written in pure Go (as much as possible, right now pcre doesn't exist in pure go and require usage of libpcre).

Why?

That's a good question. PHP is a nice language but is having trouble keeping up with modern languages. This implementation, while far from finished, is trying to make a number of things possible:

  • Usage of goroutines, go channels, etc from within PHP
  • Better caching of compiled code by allowing sharing of compiled or live objects (classes, objects, etc) between running PHP scripts
  • Use Go's memory management within PHP
  • Ability to run functions or code sandboxed (including filesystem) to limit security risks
  • Easily call the PHP engine from Go to execute pieces of PHP code (user provided or legacy)

Install

In order to run php code as cli:

go get github.com/MagicalTux/goro/sapi/php-cli

Status

This is still a very early implementation and most of the core is missing.

TODO

The following needs to be done before we can call this an alpha version.

  • Fix arguments passed by reference for builtin methods
  • Error reporting, lower level of errors (warnings, etc)
  • php.ini handling
  • Streams & filesystem support
  • command line flags handling
  • Class and object implementation is still very early. Access checks are missing. Class inheritance, etc are missing
    • Class abstract
    • Builtin class methods
    • Interfaces
    • Exception throwing
    • Traits
  • break/continue needs improvement/fixing
  • declare
  • goto ?
  • namespaces
  • generators
  • predefined superglobals
  • implement Complex (curly) variable syntax (see: http://php.net/manual/en/language.types.string.php#language.types.string.parsing.complex )
  • Allow process to run in containers on linux (see https://github.com/lizrice/containers-from-scratch - would be useful to create a play interface for goro)

Extensions

Sorted by priority.

Extension Status Notes
standard 5% a lot of work remaining
json 33% Need custom impl to support php arrays
pcre 5% currently using cgo version of libpcre
session
date 1%
SPL
iconv using golang.org/x/text/transform
curl using net/http
hash 50%
mysqli
gmp 20% Using math/big
mbstring
mcrypt
openssl using crypto packages
Reflection
tokenizer already in core/tokenizer, needs to be exposed
xml...
gd without gd
bz2 1%
zlib
calendar
Phar
ctype 100%
sockets

Concepts

Process

A process object will typically be created only once in a runtime environment, and is used to keep some objects cached, as well as global stream wrapper resources. Persistant connections, run time cache, etc are stored at the Process level.

GlobalCache (optional)

A special global status intermediate between Process and Global that causes declarations of classes and functions to be kept between scripts, typically useful when using an autoloader.

Global

When a request is received or execution of a script is requested, a new Global context is created. The global context contains runtime level details such as global variables, declared functions, classes, constants, etc.

Context

Context is a local context, such as within a running function etc. Global has a root context, and each function call causes instantiation of a new context so that variables space is kept separated.

Contributing

A lot of work is needed. The most important part is improving the documentation, followed by improving support of core features (see TODO in this file), and implement individual functions from the various PHP extensions.

Writing an extension is simple. Create a directory in ext, write code prefixed with a magic function defining comment and run the tools/buildext.php script to generate bindings/etc. Add your newly created extension to the main.go of each sapi to enable it by default.

Before contributing, please join the telegram group and/or create an issue on github in order to discuss and find out which parts you can work on and how to proceed.

More Repositories

1

xkcd1446

xkcd 1446
HTML
54
star
2

grf

libgrf and grfbuilder
C
27
star
3

invpn

invpn is a decentralized vpn server aimed at high availability server architectures on multiple sites.
C++
11
star
4

proctitle

Extension allowing to change the name of the current process in PHP
C
10
star
5

webpuppeteer

Simple web puppeteer to do stuff, using Qt and Webkit
JavaScript
8
star
6

btclib

quick'n'dirty bitcoin signing lib because too lazy to reimplement ECDSA in pure PHP
C++
7
star
7

pinetd2

Portable Inet Daemon
PHP
5
star
8

nezumi-php

Nezumi PHP RO emulator
PHP
4
star
9

palmsecure

PalmSecure driver attempt
C++
4
star
10

mintchip

MintChip tests & code
PHP
4
star
11

ocra-php

OCRA implementation in PHP
PHP
4
star
12

imgur

Imgur random image puller
3
star
13

s3clfs

S3 Cluster FS
C++
3
star
14

php-git2

New libgit2 bindings for PHP
C
3
star
15

kbt

Bittorrent client written in PHP, with php-gtk based UI
PHP
3
star
16

farpd

FakeARP daemon
Shell
2
star
17

mtgox_bankruptcy

some calculations
HTML
2
star
18

door

Door control stuff
C++
2
star
19

pinetd

Portable Inet Daemon
PHP
2
star
20

gones

GoNES
Go
2
star
21

gentoo

Gentoo overlay with stuff in it
1
star
22

tpleditor

Template editor for Tibanne's template system
TypeScript
1
star
23

mdbsh

shell scripts to use with mdbtools
Shell
1
star
24

HDL

HDL tests
1
star
25

cloudconnector

Cloud Connector, ancestor of InVpn
C
1
star
26

fixedalloc

Fixed size memory allocator optimized for performance over memory usage
C
1
star
27

goupd-any

Any package downloader
Makefile
1
star
28

vt280

VT-280 Toshiba TEC automatic change machine
PHP
1
star
29

QtSocket

A multi browser websocket implementation with fallbacks for older browsers
1
star
30

orangetux

Small C program to handle pppd 3G connection (2007)
C
1
star
31

mp4salvage

Attempt at salvaging a Sony mp4 video file
PHP
1
star
32

nezumi

Nezumi RO server
C
1
star
33

dlockd

Distributed lock manager daemon
C++
1
star