PHP code example of sudiyi / ruby-marshal

1. Go to this page and download the library: Download sudiyi/ruby-marshal library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

sudiyi / ruby-marshal example snippets


use SuDiYi\RubyMarshal\RubyMarshalLoad;
use SuDiYi\RubyMarshal\UnEscape;
use SuDiYi\RubyMarshal\RubyMarshalException

try {
    $rubyMarshalLoad = new RubyMarshalLoad();
    $content = 'marshal-str'
    $arr = $rubyMarshalLoad->load($content);
} catch (RubyMarshalException $e) {
    echo "============== ERROR ==============\n";
    echo $e->getMessage() . "\n";
    var_dump($e->getErrorBody());
    echo "===================================\n";
}

|-- example
|   `-- demo.php         案例程序代码
|-- src
|   |-- Helper.php          帮助类
|   |-- Ints.php            辅助类
|   |-- RubyMarshalLoad.php 主程序类
|   `-- RubyMarshalException.php    异常类
|-- autoload.php            PSR-4 自动加载
`-- composer.json