Skip to content

tuqqu/go-php

Folders and files

NameName
Last commit message
Last commit date

Latest commit

5e82555 · Sep 13, 2024
Jan 22, 2024
Jun 19, 2024
Jun 19, 2024
Sep 13, 2024
Sep 13, 2024
Mar 31, 2023
Jun 9, 2022
Jun 19, 2024
Mar 16, 2022
Jul 28, 2023
Jun 19, 2024
Aug 31, 2024
Aug 31, 2024
Aug 31, 2024

Repository files navigation

Go-PHP

Golang interpreter written in PHP.

Example

use GoPhp\Interpreter;

$interp = Interpreter::create(<<<GO
    package main
    
    type person struct {
        name string
        age  int
    }
    
    func newPerson(name string) *person {
        p := person{name: name}
        p.age = 42

        return &p
    }

    func main() {
        s := newPerson("John Doe")
    
        println("Hello, " + s.name)
    }
GO);

$result = $interp->run();

See examples for more. To run examples:

cd ./examples/{name}
php main.php

WIP

This is a toy project, not intended for production use.

To see what is already implemented, refer to tests.

Development

install dependencies:

composer install

run tests:

make test

run make help for more commands.

Differences from the Go compiler

  • No support for real goroutines, go statements run sequentially