Download the PHP package lbreme/lexepa-srl without Composer

On this page you can find all versions of the php package lbreme/lexepa-srl. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package lexepa-srl

Lexepa-Srl

Library for lexing and parsing a serialized string in PHP.

Installing Lexepa-Srl

First, get Composer, if you don't already use it.

Next, run the following command inside the directory of your project:

composer require lbreme/lexepa-srl

How does it work?

The Lexepa-Srl library analyzes any text string coming from the result of a serialization in PHP. During the analysis a series of callback functions are called to which are passed as arguments the elements that constitute the serialized string.

We clarify with an example, which is contained in the file class-example-srl.php, which to make it work is to copy in the root of your project:

/*
We create a class derived from the Lexepa_Srl_Abstract class, which implements all the
callback functions that will be called by the analysis of the serialized string
*/
class Example_Srl extends Lexepa_Srl_Abstract
{
    /**
     * Begin of parsing
     *
     * @param string $string Original string to unserialize.
     * @param int    $offset Initial offset.
     */
    public function begin_parsing( $string, $offset ) {
        echo 'String serialized: ' . $string . '<br />';
    }

    /**
     * String length value found
     *
     * @param string $string_length String length value.
     * @param int    $offset Offset of the string length value found.
     */
    public function string_length( $string_length, $offset )
    {
        echo 'String length: ' . $string_length . '<br />';
    }

    /**
     * String value found
     *
     * @param string $string_value String value.
     * @param int    $offset Offset of the string value found.
     */
    public function string_value( $string_value, $offset )
    {
        echo 'String value: ' . $string_value . '<br />';
    }

    /**
     * Integer value found
     *
     * @param string $integer_value Integer value.
     * @param int    $offset Offset of the integer value found.
     */
    public function integer_value( $integer_value, $offset )
    {
        echo 'Integer value: ' . $integer_value . '<br />';
    }

    /**
     * Decimal value found
     *
     * @param string $decimal_value Decimal value.
     * @param int    $offset Offset of the decimal value found.
     */
    public function decimal_value( $decimal_value, $offset ) {
        echo 'Decimal value: ' . $decimal_value . '<br />';
    }

    /**
     * Boolean value found
     *
     * @param string $boolean_value It can be '0' or '1'.
     * @param int    $offset Offset of the boolean value found.
     */
    public function boolean_value( $boolean_value, $offset ) {
        echo 'Boolean value: ' . $boolean_value . '<br />';
    }

    /**
     * Null value found
     *
     */
    public function null_value() {
        echo 'Null value found' . '<br />';
    }

    /**
     * Number of items of the array found
     *
     * @param string $items_num Number of items.
     * @param int    $offset Offset of the number of items found.
     */
    public function array_items_num( $items_num, $offset ) {
        echo 'Number of items of the array: ' . $items_num . '<br />';
    }

    /**
     * End of parsing
     *
     * @param bool $parsing_result True if the string is unserializable.
     */
    public function end_parsing( $parse_result )
    {
        if ( $parse_result ) {
            echo 'Good job!' . '<br />';
        } else {
            echo 'There was an error' . '<br />';
        }
    }

    /**
     * Set error parsing the string.
     *
     * @param string $error Error parsing the string.
     */
    public function set_error( $error )
    {
        echo $error . '<br />';
    }
}

$example_srl = new Example_Srl();

/*
We instantiate the Lexepa-Srl library class, passing as arguments the $example_srl object
containing the callback functions and the serialized string
*/
$lexepa_srl  = new Lexepa_Srl( $example_srl, $myArraySerialized );

// Let's start the analysis
$lexepa_srl->parse_srl();

The result of this example is as follows:

String serialized: a:5:{s:4:"key1";s:22:"This is my first value";s:4:"key2";s:23:"This is my second value";s:4:"key3";i:20;s:4:"key4";b:1;s:4:"key5";N;}
Number of items of the array: 5
String length: 4
String value: key1
String length: 22
String value: This is my first value
String length: 4
String value: key2
String length: 23
String value: This is my second value
String length: 4
String value: key3
Integer value: 20
String length: 4
String value: key4
Boolean value: 1
String length: 4
String value: key5
Null value found
Good job!

The callback functions implemented by the Lexepa_Srl_Abstract class are contained and documented in the interface file class-lexepa-srl-interface.php

The Lexepa_Srl library was created by taking as reference the following document that specifies how an object is serialized in PHP:

https://www.phpinternalsbook.com/php5/classes_objects/serialization.html


All versions of lexepa-srl with dependencies

PHP Build Version
Package Version
Requires php Version >=7.0.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package lbreme/lexepa-srl contains the following files

Loading the files please wait ...