Download the PHP package componenta/var-export without Composer

On this page you can find all versions of the php package componenta/var-export. 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 var-export

Componenta VarExport

Componenta VarExport turns supported PHP values into deterministic, executable PHP expressions. It is designed for generated configuration and dependency-injection files: the library returns an expression only and never writes files or adds a PHP tag, return, or a terminating semicolon.

Requires PHP 8.4 or later.

Installation

Quick start

The result is ready to embed in generated PHP:

Public API

VarExport asks exporters in constructor order. An exporter returns null when it does not support a value; every string, including an empty string, completes the chain.

withDefaults() installs these public exporters in order:

  1. ScalarExporter
  2. ArrayExporter
  3. EnumExporter
  4. ClosureExporter

Supported values

Default exporters reject arbitrary objects and resources. Arrays whose next append index or internal pointer cannot be reproduced by a PHP array literal also raise ExportException; this applies to nested arrays and closure captures. A nonempty array must point to its first element: moving its pointer with next(), end(), or prev() can make it nonportable. Validation leaves the original pointer unchanged. For example, removing a numeric key can leave an array that looks identical to a literal but behaves differently on the next [] append. Config and DI integrations can add their own exporters before the defaults:

Composite exporters implement both VarExportInterface and VarExportAwareInterface. Their withVarExport() method must return a bound copy. The orchestrator replaces the original exporter with that copy, so exporter instances remain reusable.

ArrayExporter and ClosureExporter are composite exporters. When used directly, bind them first:

Closure portability

ClosureExporter reads the closure's source, verifies the reflected source location, resolves portable global functions and constants, freezes safe captures, and prints a canonical expression.

PHP automatic globals ($GLOBALS, $_SERVER, $_ENV, and the other superglobals) remain runtime lookups. They are not treated as captures and are not frozen into the generated expression.

The generated expression records whether the provider source uses strict_types. Loading it from a file compiled under the opposite mode throws ExportException instead of silently changing closure behavior.

It rejects behavior that cannot be reproduced safely in a generated file, including:

The provider source must not be modified after the runtime closure is created. PHP Reflection does not expose closure body opcodes, so a body-only edit that preserves the reflected location, signature, and captures cannot be detected safely without executing user code.

Errors

All library exceptions implement Componenta\VarExport\Exception\ExceptionInterface.

Exceptions thrown by custom exporters are not intercepted.

Development

The supported test matrix is PHP 8.4 and PHP 8.5.


All versions of var-export with dependencies

PHP Build Version
Package Version
Requires php Version ^8.4
nikic/php-parser Version ^5.8
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 componenta/var-export contains the following files

Loading the files please wait ...