Skip to content

MasterZydra/GoPHP

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

97 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Go Build and Test

GoPHP

GoPHP is an implementation of the PHP language specification written in the Go programming language.

The goals of the project are:

  • Deep dive into the PHP language syntax and the internals of its mode of operation
  • Gain more experience in writing lexers, parser and interpreter
  • Very long-term goal: Implement as many parts of the standard library and language features as needed to run a simple Laravel application 😓

More documentation:

Usage

Usage of ./goPHP:
  -h            Show help
  -dev          Run in developer mode.
  -S string     Run with built-in web server. <addr>:<port>
  -t string     Specify document root <docroot> for built-in web server.
  -f string     Parse and execute <file>.

Parse file:
cat index.php | ./goPHP or ./goPHP -f index.php

Run web server:
./goPHP -S localhost:8080 - Document root is current working directory
./goPHP -S localhost:8080 -dev - Web server in developer mode
./goPHP -S localhost:8080 -t /srv/www/html - Document root is /srv/www/html

Development

Compile and run
go run ./...

Build executable
go build -o . ./...

Run all tests
go test -v ./...

See test coverage
go test -coverprofile=coverage.out ./...
go tool cover -html=coverage.out

Run official PHP phpt test cases

There are a lot of test cases in the source repository for PHP under the folder tests.
In order to test the GoPHP implementation against this cases the binary goPhpTester can be used.

Usage:
./goPhpTester <list of directory or phpt-file>

Examples:
./goPhpTester php-src/tests
./goPhpTester php-src/tests/basic/001.phpt

Used resources

For some part of this project, the following resources were used as a guide, inspiration, or concept: