Download the PHP package atk14/packer without Composer

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

Packer

Tests

Converts any PHP variable into a URL-safe string — and back. Supports HMAC signing, AES-256-CBC encryption, and gzip compression.

The Packer is particularly useful for:

In all cases, the value itself is securely hidden from the user and protected against unauthorized tampering.

Installation

Basic usage

Every packed string is signed with HMAC-SHA256. Tampered or forged strings are rejected on unpack.

Configuration

Set a secret before using the library — either via a constant or SetSalt():

Important: Never use the default salt ("Put_Some_Secret_Text_Here") in production. Anyone with access to the source code could forge valid packed strings.

Global defaults can also be set via constants:

Constant Default Description
PACKER_CONSTANT_SECRET_SALT "Put_Some_Secret_Text_Here" Secret for signing and encryption
PACKER_ENABLE_ENCRYPTION false Enable AES-256-CBC encryption
PACKER_USE_COMPRESS false Enable gzip compression
PACKER_USE_JSON_SERIALIZATION true Use JSON (true) or PHP serialize() (false)
PACKER_SIGNATURE_LENGTH 16 Number of Base64URL characters used as the HMAC-SHA256 signature (8–43)

Encryption

Each call to Pack() with encryption generates a random IV, so the same input produces a different output every time.

Per-call password (extra_salt)

Useful when different users or sessions need isolated packed values:

Compression

Compression is detected automatically on unpack — no need to pass any option.

Decode() — inline unpacking

Decode() is a shorthand for Unpack() that returns the value directly instead of using an output parameter:

To distinguish a failed unpack from a legitimately packed null, use the optional second parameter:

Method reference

Packer::Pack($variable, $options = []): string

Packs a variable into a URL-safe string.

Option Type Default Description
enable_encryption bool PACKER_ENABLE_ENCRYPTION Encrypt with AES-256-CBC
use_compress bool PACKER_USE_COMPRESS Compress with gzip
use_json_serialization bool PACKER_USE_JSON_SERIALIZATION JSON vs PHP serialize
extra_salt string "" Additional secret for signing and encryption

Packer::Unpack($packed, &$out, $options = []): bool

Unpacks a string. Returns true on success, false if the string is invalid or tampered.

Accepts the same options as Pack(), except use_compress (auto-detected from the packed string).

Packer::Decode($packed, &$decoded = false): mixed

Shorthand for Unpack(). Returns the unpacked value, or null on failure. Sets $decoded to true/false.

Packer::SetSalt($salt): string

Sets the runtime secret salt. Returns the previous salt.

Security notes

Requirements

License

MIT


All versions of packer with dependencies

PHP Build Version
Package Version
Requires php Version >=5.6.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 atk14/packer contains the following files

Loading the files please wait ...