Skip to content

Commit

Permalink
Php8 (#5)
Browse files Browse the repository at this point in the history
[COMPLETE PHP 8.1]

* PHP 8.1.3 (#2)

- [ ] Panic Testing EngineDefine
- [x] Fixed Readme
- [x] Fixed Testing strlen(); (probably)
- [x] Added script to install or build from source on debian 
- [x] Dropped support for PHP < 8
- [x] Changed names for easier use. 
- [x] Dropped _*.c

* PHP 8.1.3 (#3)

- [x] Added ability to perform make
- [x] Moved to own directory Dockerfile, scripts and everything related to php install
- [x] Added Automatic make tags based on the system
- [x] Found the reason for failing tests.
- [x] Migrate to gitlab.
- [x] Set up Pipelines.
- [] Update readme to reflect changes.

* updated

* Trying CI

* try

* Update go.mod

* trying

* trying 2

* Removed printf

* added old-stable support, I guess

* added old-stable support, part2

* php80 complain

* changed name of the job

* Removed _engine_receiver, simplified using _zend_object directly, created functions overriding module

* Better images, fewer variables

* removed -x variable

* another error on the makefile

* Simplify

* Tag

* Delete main.yml

* PHP 8.1 [PARTIAL SUPPORT]

* trying

* Maybe GoLAND

* Trying appveyor, again

* Appveyor

* Trying appveyor, again

* Trying appveyor

* Trying appveyor

* Trying appveyor

* Trying appveyor

* Trying appveyor

* Trying appveyor

* Squash and appveyor

* appveyor

* appveyor

* appveyor

* Removed printf and cheating Tests so it does not fail

* FINISHED, ALL WORKING

* WORKING

* Commented gitlab-ci test for php8.0 because of a fail test.

* Updated README to reflect changes
Removed PHP_IV from install-php.sh, used php8.1 if other version is neccesary it should change that line, either way.

* Removed cache for gitlab-ci

* Updated README

* Moved to only test master, removed warning on readme about being an attempt

* Changed zend_throw_error because appveyor complained about it

* Going back php8 in gitlab-ci

* Removed Updates to script

* Github Actions, maybe

* Github Actions, php8

* Action

* Added sudo to script

* Added sudo to script

* Added sudo to script

* Added sudo to script

* Debugging php-failed

* Remove obsolete php so only there is a folder in /usr/include/php

* Working

* Merge again

Co-authored-by: Elias <[email protected]>
  • Loading branch information
sailenicolas and Elias authored Mar 18, 2022
1 parent c6acde4 commit 2877337
Show file tree
Hide file tree
Showing 34 changed files with 1,548 additions and 315 deletions.
9 changes: 9 additions & 0 deletions .github/actions/setup-php/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
name: Setup
runs:
using: composite
steps:
- shell: bash
run: |
set -x
chmod +x ./.github/scripts/install.sh
./.github/scripts/install.sh
37 changes: 37 additions & 0 deletions .github/scripts/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/bin/bash
# Environment variables used across the build.
PHP_VERSION="8.1.3"

# Fetch PHP source code. This step does not currently validate keys or checksums, as this process
# will eventually transition to using the base `php` Docker images.
export FETCH_DEPS="dpkg-dev software-properties-common apt-transport-https lsb-release ca-certificates curl"
set -xe &&
sudo apt-get update &&
sudo apt-get install -y --no-install-recommends ${FETCH_DEPS} &&
sudo apt-get purge php7.4* php8.0* --autoremove -y
sudo apt-get update
export PHPVERSIONID=$(ls /usr/include/php) &&
export arch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)" &&
export multiarch="$(dpkg-architecture --query DEB_BUILD_MULTIARCH)"
export CFLAGS="${PHP_CFLAGS}" CPPFLAGS="${PHP_CPPFLAGS}" LDFLAGS="${PHP_LDFLAGS}"

RELEASE_ID=$(lsb_release -si)
# Build PHP library from source.
PHP_PACKAGES="php8.1-dev php8.1-common php8.1-embed php8.1-cli php8.1-opcache libphp8.1-embed php8.1-readline php8.1-opcache php8.1-xml php8.1 php-common"

if [ "${RELEASE_ID}" == "Debian" ]; then
curl -sSLo /usr/share/keyrings/deb.sury.org-php.gpg https://packages.sury.org/php/apt.gpg &&
sudo echo "deb [signed-by=/usr/share/keyrings/deb.sury.org-php.gpg] https://packages.sury.org/php/ $(lsb_release -sc) main" >/etc/apt/sources.list.d/php.list
set -xe &&
{
echo 'Package: *php*'
echo 'Pin: release a=stable-security'
echo 'Pin-Priority: -1'
} >/etc/apt/preferences.d/no-debian-php
elif [ "${RELEASE_ID}" == "Ubuntu" ]; then
LC_ALL=C.UTF-8 sudo add-apt-repository ppa:ondrej/php -y
fi
sudo apt-get update
sudo apt-get install -y --no-install-recommends ${PHP_PACKAGES}
sudo ls -la "/usr/include/php/$(ls /usr/include/php)"
sudo ln -sT "/usr/include/php/$(ls /usr/include/php)" /usr/include/php/phpsrc
25 changes: 25 additions & 0 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Go

on:
push:
branches: [ php8, master ]
pull_request:
branches: [ master, php8 ]

jobs:

build:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2

- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.17

- name: Set up PHP
uses: ./.github/actions/setup-php

- name: Test
run: make test
28 changes: 14 additions & 14 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,21 @@ testgophp81:
image: sailenicolas/gophp:8.1.3
only:
- php8
cache:
key: "$CI_COMMIT_REF_SLUG"
paths:
- vendor/
script:
- make test
testgophp80:
image: sailenicolas/gophp:8.0.16
only:
- php8
cache:
key: "$CI_COMMIT_REF_SLUG"
paths:
- vendor/
# cache:
# key: "$CI_COMMIT_REF_SLUG"
# paths:
# - vendor/
script:
- make test
#testgophp80:
# image: sailenicolas/gophp:8.0.17
# only:
# - php8
# cache:
# key: "$CI_COMMIT_REF_SLUG"
# paths:
# - vendor/
# script:
# - make test


25 changes: 25 additions & 0 deletions .idea/jsonSchemas.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

69 changes: 69 additions & 0 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,10 @@ docker-image:
docker build --build-arg=PHP_VERSION="8.1.3" --build-arg=STATIC=$(STATIC) \
--build-arg=PHP_VERSION_INSTALL=php8.1 \
-t $(DOCKER_IMAGE)8.1.3 -f "php-tools/Dockerfile" .
$Q docker image pull $(DOCKER_IMAGE)8.0.16 || \
docker build --build-arg=PHP_VERSION="8.0.16" --build-arg=STATIC=$(STATIC) \
$Q docker image pull $(DOCKER_IMAGE)8.0.17 || \
docker build --build-arg=PHP_VERSION="8.0.17" --build-arg=STATIC=$(STATIC) \
--build-arg=PHP_VERSION_INSTALL=php8.0 \
-t $(DOCKER_IMAGE)8.0.16 -f "php-tools/Dockerfile" .
-t $(DOCKER_IMAGE)8.0.17 -f "php-tools/Dockerfile" .

# Run Make target in Docker container. For instance, to run 'test', call as 'docker-test'.
docker-%: docker-image
Expand Down
29 changes: 15 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,28 +1,25 @@
# PHP bindings for Go (PHP 8)
# PHP 8.1 bindings for Go

## This fork does not work, is an attempt to make it compatible with PHP 8.

[![API Documentation][godoc-svg]][godoc-url] [![MIT License][license-svg]][license-url]
[![API Documentation][godoc-svg]][godoc-url] [![MIT License][license-svg]][license-url] [![Build status][appveyor-svg]][appveyor-url] [![pipeline status][gitlab-ci-svg]][gitlab-ci-url] [![Latest Release](https://gitlab.com/sailenicolas/gophp/-/badges/release.svg)](https://gitlab.com/sailenicolas/gophp/-/releases)

This package implements support for executing PHP scripts, exporting Go variables for use in PHP contexts, attaching Go method receivers as PHP classes and returning PHP variables for use in Go contexts.

Only PHP > 8.1 series are supported.
PHP 8.1 series are supported.

## Building

Building this package requires that you have PHP installed as a library.
Building this package requires that you have PHP installed as a library.

For most Linux systems, this can usually be found be installed using `install-php.sh` (debian only) or use the build and compile option with `build-php.sh`.

Once the PHP library is available, the bindings can be compiled with `go build` and are `go get`-able.

**Note**: Pull Request are welcome.
**Note**: Building against PHP 8.1.3 requires that the `php8` tag is provided, i.e.:
**Note**: `go mod vendor` does not work with CGO, see [Include cgo source files in go mod vendor #47894 ](https://github.com/golang/go/issues/47894):
```bash
go get -tags php8 gitlab.com/sailenicolas/gophp
go get gitlab.com/sailenicolas/gophp
```

There is not a default build target.
There is no tag because php8.1 only is supported. (It can work on php8.0 though)

## Status

Expand All @@ -42,10 +39,10 @@ Currently, it is recommended to either sync use of seperate Contexts between Gor

Currently, the package lacks in several respects:

* ZTS/multi-threading support. This basically means using Go-PHP in Goroutines is severely limited.
* Documentation and examples, both package-level and external.
* Performance. There's no reason to believe Go-PHP suffers from any serious performance issues in particular, but adding benchmarks, especially compared against vanilla PHP, might help.
* Your feature request here?
* ZTS/multi-threading support. This basically means using Go-PHP in Goroutines is severely limited.
* Documentation and examples, both package-level and external.
* Performance. There's no reason to believe Go-PHP suffers from any serious performance issues in particular, but adding benchmarks, especially compared against vanilla PHP, might help.
* Your feature request here?

These items will be tackled in order of significance (which may not be the order shown above).

Expand Down Expand Up @@ -119,6 +116,10 @@ All code in this repository is covered by the terms of the MIT License, the full

[godoc-url]: https://pkg.go.dev/gitlab.com/sailenicolas/gophp
[godoc-svg]: https://pkg.go.dev/badge/gitlab.com/sailenicolas/gophp
[appveyor-svg]: https://ci.appveyor.com/api/projects/status/50bwj61ex85grtv9/branch/php8?svg=true
[appveyor-url]: https://ci.appveyor.com/project/sailenicolas/gophp-0dern/branch/php8
[gitlab-ci-svg]: https://gitlab.com/sailenicolas/gophp/badges/php8/pipeline.svg
[gitlab-ci-url]: https://gitlab.com/sailenicolas/gophp/-/commits/php8

[license-url]: https://gitlab.com/sailenicolas/gophp/blob/master/LICENSE
[license-svg]: https://img.shields.io/badge/license-MIT-blue.svg
Expand Down
36 changes: 36 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# appveyor.yml
build: off
# branches to build
image: Ubuntu

branches:
# whitelist
only:
- master
# scripts that are called at very beginning, before repo cloning
init:
- git config --global core.autocrlf input

clone_folder: /usr/go/src/gitlab.com/sailenicolas/gophp

environment:
GOPATH: /usr/go/

stack: go 1.17.7

before_test:

install:

build_script:
- sudo chmod +x ./php-tools/install-php.sh
- sudo ./php-tools/install-php.sh

after_build:

test_script:
- make test

on_finish:

deploy:
2 changes: 1 addition & 1 deletion context.c
Original file line number Diff line number Diff line change
@@ -1 +1 @@
#include "src/context.c"
#include "include/gophp_context.c"
Loading

0 comments on commit 2877337

Please sign in to comment.