Giter VIP home page Giter VIP logo

hprose-pecl's Introduction

Hprose extension for PHP

Join the chat at https://gitter.im/hprose/hprose-pecl Build Status Supported PHP versions: 5.2 .. 7.3 GitHub release License

Introduction

Hprose is a High Performance Remote Object Service Engine.

It is a modern, lightweight, cross-language, cross-platform, object-oriented, high performance, remote dynamic communication middleware. It is not only easy to use, but powerful. You just need a little time to learn, then you can use it to easily construct cross language cross platform distributed application system.

Hprose supports many programming languages, for example:

  • AAuto Quicker
  • ActionScript
  • ASP
  • C++
  • Dart
  • Delphi/Free Pascal
  • dotNET(C#, Visual Basic...)
  • Golang
  • Java
  • JavaScript
  • Node.js
  • Objective-C
  • Perl
  • PHP
  • Python
  • Ruby
  • ...

Through Hprose, You can conveniently and efficiently intercommunicate between those programming languages.

This project is the implementation of Hprose extension for PHP.

Installation

There are many ways to build the package. Below you can find details for most useful ways of package building:


Way 1: Building the package with PHP

  1. Create ext/hprose folder in the php-source-folder. Copy all files from the package into created folder.

  2. Run

    ./buildconf
    

    to rebuild PHP's configure script.

  3. Compile php with option:

    --enable-hprose to build bundled into PHP module

    --enable-hprose=shared to build dinamycally loadable module


Way 2: Building the package with phpize utility

  1. Unpack contents of the package.

  2. Run

    phpize
    

    script, which will prepare environment for building hprose package.

  3. Run

    ./configure --enable-hprose=shared
    

    to generate makefile.

  4. Run

    make
    

    to build hprose extension library. It will be placed into ./modules folder.

  5. Run

    make install
    

    to install hprose extension library into PHP


Way 3: Install via pecl

  1. Run:

     pecl install hprose
    

    That's all.


Usage

This extension is a part of Hprose for PHP, It only implements hprose serialize, unserialize and RPC protocol abstraction layer. The real http client and server implementation are written in PHP. If you want to know how to use it, look at here:

http://github.com/hprose/hprose-php

hprose-pecl's People

Contributors

andot avatar gitter-badger avatar lao-liu avatar remicollet avatar tinkoliu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

hprose-pecl's Issues

php7在安装了opcache扩展下运行的问题

env:php7 + opcache + fpm
location:hprose_writer.h function _hprose_writer_write_array

    HashTable *ht = Z_ARRVAL_P(val); // 这个val多进程共享
    int32_t i = zend_hash_num_elements(ht);
    if (refer) {
        hprose_writer_refer_set(refer, val);
    }
    hprose_bytes_io_putc(stream, HPROSE_TAG_LIST);
    if (i) {
        hprose_bytes_io_write_int(stream, i);
    }
    hprose_bytes_io_putc(stream, HPROSE_TAG_OPENBRACE);
    if (i) {
        zend_hash_internal_pointer_reset(ht);
        for (; i > 0; --i) {
#if PHP_MAJOR_VERSION < 7
            zval **e;
            zend_hash_get_current_data(ht, (void **)&e);
            _hprose_writer_serialize(_this, refer, stream, *e TSRMLS_CC);
#else
            zval *e = zend_hash_get_current_data(ht);
            _hprose_writer_serialize(_this, refer, stream, e TSRMLS_CC);
#endif
            zend_hash_move_forward(ht);
        }
    }

zval没有做分离,fpm下两个进程并发执行,会造成数组循环的数据缺失问题

Failed test in 32bits build

 + /usr/bin/php -n run-tests.php --show-diff
 =====================================================================
 PHP         : /usr/bin/php 
 PHP_SAPI    : cli
 PHP_VERSION : 5.4.39
 ZEND_VERSION: 2.4.0
 PHP_OS      : Linux - Linux schrodingerscat.famillecollet.com 3.19.3-200.fc21.x86_64 #1 SMP Thu Mar 26 21:39:42 UTC 2015 i686
 INI actual  : /builddir/build/BUILD/php-pecl-hprose-1.0.0/NTS
 More .INIs  :  
 CWD         : /builddir/build/BUILD/php-pecl-hprose-1.0.0/NTS
 Extra dirs  : 
 VALGRIND    : Not used
 =====================================================================
 TIME START 2015-04-02 07:44:22
 =====================================================================
 TEST 1/8 [tests/bytes_io.phpt]
 PASS Test that the Hprose\BytesIO class works. [tests/bytes_io.phpt] 
 TEST 2/8 [tests/class_manager.phpt]
 PASS Test that the Hprose\ClassManager class works. [tests/class_manager.phpt] 
 TEST 3/8 [tests/formatter.phpt]
 PASS Test that the Hprose\Formatter class works. [tests/formatter.phpt] 
 TEST 4/8 [tests/raw_reader.phpt]
 ========DIFF========
 011+ d-2147483648;
 011- i-2147483648;
 013+ d2147483648;
 013- l2147483648;
 ========DONE========
 FAIL Test that the Hprose\RawReader class works. [tests/raw_reader.phpt] 
 TEST 5/8 [tests/reader.phpt]
 ========DIFF========
 011+ float(-2147483648)
 011- int(-2147483648)
 013+ float(2147483648)
 013- string(10) "2147483648"
 ========DONE========
 FAIL Test that the Hprose\Reader class works. [tests/reader.phpt] 
 TEST 6/8 [tests/result_mode.phpt]
 PASS Test that the Hprose\ResultMode class works. [tests/result_mode.phpt] 
 TEST 7/8 [tests/tags.phpt]
 PASS Test that the Hprose\Tags class works. [tests/tags.phpt] 
 TEST 8/8 [tests/writer.phpt]
 ========DIFF========
 001+ 0123456789d-2147483648;i2147483647;d2147483648;d3.1415926535898;NI-I+tfenu我s2"🆚"
 001- 0123456789i-2147483648;i2147483647;l2147483648;d3.1415926535898;NI-I+tfenu我s2"🆚"
 ========DONE========
 FAIL Test that the Hprose\Writer class works. [tests/writer.phpt] 
 =====================================================================
 TIME END 2015-04-02 07:44:22
 =====================================================================
 TEST RESULT SUMMARY
 ---------------------------------------------------------------------
 Exts skipped    :    0
 Exts tested     :   29
 ---------------------------------------------------------------------
 Number of tests :    8                 8
 Tests skipped   :    0 (  0.0%) --------
 Tests warned    :    0 (  0.0%) (  0.0%)
 Tests failed    :    3 ( 37.5%) ( 37.5%)
 Expected fail   :    0 (  0.0%) (  0.0%)
 Tests passed    :    5 ( 62.5%) ( 62.5%)
 ---------------------------------------------------------------------
 Time taken      :    0 seconds
 =====================================================================
 =====================================================================
 FAILED TEST SUMMARY
 ---------------------------------------------------------------------
 Test that the Hprose\RawReader class works. [tests/raw_reader.phpt]
 Test that the Hprose\Reader class works. [tests/reader.phpt]
 Test that the Hprose\Writer class works. [tests/writer.phpt]
 =====================================================================

PHP 7.1 build

In file included from /builddir/build/BUILD/php71-php-pecl-hprose-1.6.4/NTS/php_hprose.c:31:0:
/builddir/build/BUILD/php71-php-pecl-hprose-1.6.4/NTS/hprose_reader.h: In function 'hprose_reader_read_object_without_tag':
/builddir/build/BUILD/php71-php-pecl-hprose-1.6.4/NTS/hprose_reader.h:660:49: error: 'zend_executor_globals {aka struct _zend_executor_globals}' has no member named 'scope'
/builddir/build/BUILD/php71-php-pecl-hprose-1.6.4/NTS/hprose_reader.h:661:19: error: 'zend_executor_globals {aka struct _zend_executor_globals}' has no member named 'scope'
  EG(scope) = scope;
                   ^
In file included from /builddir/build/BUILD/php71-php-pecl-hprose-1.6.4/NTS/php_hprose.c:31:0:
/builddir/build/BUILD/php71-php-pecl-hprose-1.6.4/NTS/hprose_reader.h:712:19: error: 'zend_executor_globals {aka struct _zend_executor_globals}' has no member named 'scope'
  EG(scope) = old_scope;
                   ^
In file included from /builddir/build/BUILD/php71-php-pecl-hprose-1.6.4/NTS/php_hprose.c:29:0:
/builddir/build/BUILD/php71-php-pecl-hprose-1.6.4/NTS/php_hprose.c: At top level:
/builddir/build/BUILD/php71-php-pecl-hprose-1.6.4/NTS/hprose_writer.h:376:13: warning: '_hprose_writer_write_array' defined but not used [-Wunused-function]
 static void _hprose_writer_write_array(hprose_writer *_this, hprose_writer_refer *refer, hprose_bytes_io *stream, zval *val TSRMLS_DC) {
             ^
In file included from /builddir/build/BUILD/php71-php-pecl-hprose-1.6.4/NTS/php_hprose.c:29:0:
/builddir/build/BUILD/php71-php-pecl-hprose-1.6.4/NTS/hprose_writer.h:538:13: warning: '_hprose_writer_write_list' defined but not used [-Wunused-function]
 static void _hprose_writer_write_list(hprose_writer *_this, hprose_writer_refer *refer, hprose_bytes_io *stream, zval *val TSRMLS_DC) {
             ^
/builddir/build/BUILD/php71-php-pecl-hprose-1.6.4/NTS/hprose_writer.h:552:13: warning: '_hprose_writer_write_list_with_ref' defined but not used [-Wunused-function]
 static void _hprose_writer_write_list_with_ref(hprose_writer *_this, hprose_writer_refer *refer, hprose_bytes_io *stream, zval *val TSRMLS_DC) {
             ^
/builddir/build/BUILD/php71-php-pecl-hprose-1.6.4/NTS/hprose_common.c: In function '__get_fcall_info_cache':
/builddir/build/BUILD/php71-php-pecl-hprose-1.6.4/NTS/hprose_common.c:65:46: error: 'zend_executor_globals {aka struct _zend_executor_globals}' has no member named 'scope'
/builddir/build/BUILD/php71-php-pecl-hprose-1.6.4/NTS/hprose_common.c:83:46: error: 'zend_executor_globals {aka struct _zend_executor_globals}' has no member named 'scope'
/builddir/build/BUILD/php71-php-pecl-hprose-1.6.4/NTS/hprose_common.c: In function '__function_invoke_args':
/builddir/build/BUILD/php71-php-pecl-hprose-1.6.4/NTS/hprose_common.c:232:8: error: 'zend_fcall_info {aka struct _zend_fcall_info}' has no member named 'function_table'
     fci.function_table = NULL;
        ^
/builddir/build/BUILD/php71-php-pecl-hprose-1.6.4/NTS/hprose_common.c:240:8: error: 'zend_fcall_info {aka struct _zend_fcall_info}' has no member named 'symbol_table'
     fci.symbol_table = NULL;
        ^
/builddir/build/BUILD/php71-php-pecl-hprose-1.6.4/NTS/hprose_common.c: In function '__function_invoke':
/builddir/build/BUILD/php71-php-pecl-hprose-1.6.4/NTS/hprose_common.c:446:8: error: 'zend_fcall_info {aka struct _zend_fcall_info}' has no member named 'function_table'
     fci.function_table = NULL;
        ^
/builddir/build/BUILD/php71-php-pecl-hprose-1.6.4/NTS/hprose_common.c:454:8: error: 'zend_fcall_info {aka struct _zend_fcall_info}' has no member named 'symbol_table'
     fci.symbol_table = NULL;
        ^
/builddir/build/BUILD/php71-php-pecl-hprose-1.6.4/NTS/hprose_common.c: In function '__create_php_object':
/builddir/build/BUILD/php71-php-pecl-hprose-1.6.4/NTS/hprose_common.c:739:12: error: 'zend_fcall_info {aka struct _zend_fcall_info}' has no member named 'function_table'
         fci.function_table = EG(function_table);
            ^
/builddir/build/BUILD/php71-php-pecl-hprose-1.6.4/NTS/hprose_common.c:741:12: error: 'zend_fcall_info {aka struct _zend_fcall_info}' has no member named 'symbol_table'
         fci.symbol_table = NULL;
            ^
/builddir/build/BUILD/php71-php-pecl-hprose-1.6.4/NTS/hprose_common.c:750:46: error: 'zend_executor_globals {aka struct _zend_executor_globals}' has no member named 'scope'
Makefile:196: recipe for target 'hprose_common.lo' failed
make: *** [hprose_common.lo] Error 1
/builddir/build/BUILD/php71-php-pecl-hprose-1.6.4/NTS/hprose_bytes_io.c: In function 'zim_hprose_bytes_io_readString':
/builddir/build/BUILD/php71-php-pecl-hprose-1.6.4/NTS/hprose_bytes_io.c:132:18: warning: unused variable 's' [-Wunused-variable]
     zend_string *s;
                  ^

Segmentation fault

类定义:

class Foo
{
    protected $relations = [];

    protected $name = 2;

    /**
     * Set the specific relationship in the model.
     *
     * @param  string  $relation
     * @param  mixed  $value
     * @return $this
     */
    public function setRelation($relation, $value)
    {
        $this->relations[$relation] = $value;

        return $this;
    }
}

序列化方法

function encode($result)
{
      $stream = new BytesIO();
      $writer = new Writer($stream, false);
      $stream->write(Tags::TagResult);
      if (0 === ResultMode::Serialized) {
          $stream->write($result);
      }
      else {
          $writer->reset();
          $writer->serialize($result);
       }

      $data = $stream->toString();

      return $data;
}

调用:

$foo = new Foo();
$foo_2 = new Foo();
$foo->setRelation('sublabel', [$foo_2]);
var_dump(encode($foo));

会触发Segmentation fault, 调试了一下,里面的循环会影响到外面循环的nInternalPointer, 没再继续研究, 求助大佬帮忙看一下……^_^
(环境: php: 7.1.6, hprose: master版本也可以复现)

Build against 7.0.0alpha2

API change breaks the build...

Build time

hprose_service.c:1720:9: warning: implicit declaration of function 'zend_exception_get_base' [-Wimplicit-function-declaration]

Run time

 PHP Warning:  PHP Startup: Unable to load dynamic library '/builddir/build/BUILDROOT/php70-php-pecl-hprose-1.5.4-2.fc21.remi.x86_64/opt/remi/php70/root/usr/lib64/php/modules/hprose.so' - /builddir/build/BUILDROOT/php70-php-pecl-hprose-1.5.4-2.fc21.remi.x86_64/opt/remi/php70/root/usr/lib64/php/modules/hprose.so: undefined symbol: zend_exception_get_base in Unknown on line 0

1.6.2: Broken build PHP 5.x

Build ok (lot of warnigns), but:

 PHP Warning:  PHP Startup: Unable to load dynamic library '/dev/shm/BUILDROOT/php-pecl-hprose-1.6.2-1.fc23.remi.5.6.x86_64/usr/lib64/php/modules/hprose.so' - /dev/shm/BUILDROOT/php-pecl-hprose-1.6.2-1.fc23.remi.5.6.x86_64/usr/lib64/php/modules/hprose.so: undefined symbol: zend_error_noreturn in Unknown on line 0

Line termination inconsistency

Can you please check for line termination in generated tarball.

 $ file *.c *.h src/*.c include/*.h
 hprose.c:                       C source, ASCII text, with CRLF line terminators
 php_hprose.h:                   C source, ASCII text, with CRLF line terminators
 include/hprose.h:               C source, ASCII text, with CRLF line terminators
 ...

All others files are "C source, ASCII text"

php7.3 版本中pecl install hprose 报错

Makefile:196: recipe for target 'hprose_common.lo' failed
make: *** [hprose_common.lo] Error 1
ERROR: `make' failed

使用github上面的源码安装则没有这个问题

Failed tests with PHP 7.0

 + /opt/remi/php70/root/usr/bin/php -n run-tests.php --show-diff
 =====================================================================
 PHP         : /opt/remi/php70/root/usr/bin/php 
 PHP_SAPI    : cli
 PHP_VERSION : 7.0.0-dev
 ZEND_VERSION: 3.0.0-dev
 PHP_OS      : Linux - Linux schrodingerscat.famillecollet.com 3.19.3-200.fc21.x86_64 #1 SMP Thu Mar 26 21:39:42 UTC 2015 x86_64
 INI actual  : /builddir/build/BUILD/php70-php-pecl-hprose-1.0.0/NTS
 More .INIs  :  
 CWD         : /builddir/build/BUILD/php70-php-pecl-hprose-1.0.0/NTS
 Extra dirs  : 
 VALGRIND    : Not used
 =====================================================================
 TIME START 2015-04-02 07:41:03
 =====================================================================
 TEST 1/8 [tests/bytes_io.phpt]
 PASS Test that the Hprose\BytesIO class works. [tests/bytes_io.phpt] 
 TEST 2/8 [tests/class_manager.phpt]
 PASS Test that the Hprose\ClassManager class works. [tests/class_manager.phpt] 
 TEST 3/8 [tests/formatter.phpt]
 ========DIFF========
 014+ 
 015+ Termsig=11
 ========DONE========
 FAIL Test that the Hprose\Formatter class works. [tests/formatter.phpt] 
 TEST 4/8 [tests/raw_reader.phpt]
 ========DIFF========
 036+ 
 037+ Termsig=6
 ========DONE========
 FAIL Test that the Hprose\RawReader class works. [tests/raw_reader.phpt] 
 TEST 5/8 [tests/reader.phpt]
 ========DIFF========
 096+ Termsig=11
 ========DONE========
 FAIL Test that the Hprose\Reader class works. [tests/reader.phpt] 
 TEST 6/8 [tests/result_mode.phpt]
 PASS Test that the Hprose\ResultMode class works. [tests/result_mode.phpt] 
 TEST 7/8 [tests/tags.phpt]
 PASS Test that the Hprose\Tags class works. [tests/tags.phpt] 
 TEST 8/8 [tests/writer.phpt]
 ========DIFF========
 004+ 
 005+ Termsig=11
 ========DONE========
 FAIL Test that the Hprose\Writer class works. [tests/writer.phpt] 
 =====================================================================
 TIME END 2015-04-02 07:41:05
 =====================================================================
 TEST RESULT SUMMARY
 ---------------------------------------------------------------------
 Exts skipped    :    0
 Exts tested     :   17
 ---------------------------------------------------------------------
 Number of tests :    8                 8
 Tests skipped   :    0 (  0.0%) --------
 Tests warned    :    0 (  0.0%) (  0.0%)
 Tests failed    :    4 ( 50.0%) ( 50.0%)
 Expected fail   :    0 (  0.0%) (  0.0%)
 Tests passed    :    4 ( 50.0%) ( 50.0%)
 ---------------------------------------------------------------------
 Time taken      :    2 seconds
 =====================================================================
 =====================================================================
 FAILED TEST SUMMARY
 ---------------------------------------------------------------------
 Test that the Hprose\Formatter class works. [tests/formatter.phpt]
 Test that the Hprose\RawReader class works. [tests/raw_reader.phpt]
 Test that the Hprose\Reader class works. [tests/reader.phpt]
 Test that the Hprose\Writer class works. [tests/writer.phpt]
 =====================================================================

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.