Home
Docs
GitHub
Pricing
Blog
Log In

Run Sandworm Audit for your App

Get started
Hold on, we're currently generating a fresh version of this report
Generated on Apr 16, 2024 via composer

symfony/var-exporter v4.4.40

Allows exporting any serializable PHP data structure to plain PHP code
Package summary
Share
0
issues
1
license
2
MIT
Package created
29 Aug 2018
Version published
30 Mar 2022
Maintainers
1
Total deps
2
Direct deps
1
License
MIT

Issues

0
This package has no issues

Licenses

MIT License

Permissive
OSI Approved
This is a human-readable summary of (and not a substitute for) the license. Disclaimer.
Can
commercial-use
modify
distribute
sublicense
private-use
Cannot
hold-liable
Must
include-copyright
include-license
2 Packages, Including:
symfony/polyfill-php80@v1.29.0
symfony/var-exporter@v4.4.40
Disclaimer

This deed highlights only some of the key features and terms of the actual license. It is not a license and has no legal value. You should carefully review all of the terms and conditions of the actual license before using the licensed material.

Sandworm is not a law firm and does not provide legal services. Distributing, displaying, or linking to this deed or the license that it summarizes does not create a lawyer-client or any other relationship.

Direct Dependencies

1
All Dependencies CSV
β“˜ This is a list of symfony/var-exporter 's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.
NameVersionSizeLicenseTypeVulnerabilities
symfony/polyfill-php80v1.29.0-MIT
prod

Visualizations

Frequently Asked Questions

What does symfony/var-exporter do?

The Symfony/Var-Exporter is a PHP package that aids in exporting any serializable PHP data structure into plain PHP code, preserving all the semantics associated with the serialization mechanism of PHP. It offers performance advantages over the typical serialization methods such as serialize() or igbinary, thanks to OPcache, and works seamlessly with any serializable PHP value. Beyond serialization, it also includes classes for creating objects without calling constructors or other methods (Instantiator::instantiate()), and setting the properties of an existing object (Hydrator::hydrate()). Moreover, it provides lazy-loading characteristics via Lazy*Trait classes.

How do you use symfony/var-exporter?

To utilize the Symfony/Var-Exporter, you first need to install it via composer. Once installed, you can directly use its methods in your code. To perform data serialization, you can use the VarExporter::export() method. Here is a basic usage example:

use Symfony\Component\VarExporter\VarExporter;

$data = [
    'a' => 1, 
    'b' => 2
];   // Sample data to be serialized

$serialized = VarExporter::export($data);  // Serializing the data

To instantiate an object without calling its constructor, you can use Instantiator::instantiate(). For updating an object's properties, Hydrator::hydrate() comes into play. Here's a simple example:

use Symfony\Component\VarExporter\Instantiator;

$instance = Instantiator::instantiate(SomeClass::class); // Creating instance of SomeClass without using constructor

use Symfony\Component\VarExporter\Hydrator;

Hydrator::hydrate($instance, ['property' => 'value']); // Set the properties of the instance

For leveraging lazy-loading, Lazy*Trait can be utilized. Here's an instance of creating a lazy-loading object:

use Symfony\Component\VarExporter\Cloner\LazyGhostTrait;

class MyClass
{
    use LazyGhostTrait;

    // class definition
}

MyClass::createLazyGhost(function (MyClass $instance): void {  // named initializer
    // initialization logic here
});

Where are the symfony/var-exporter docs?

The complete and detailed documentation for Symfony/Var-Exporter is available on the official Symfony website at https://symfony.com/doc/current/components/var_exporter.html. This documentation provides deep insights into how to correctly use the package, explanations about its core concepts, and extensive code examples for different use-cases.