PHPackages                             ucscode/local-storage - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Security](/categories/security)
4. /
5. ucscode/local-storage

ActiveLibrary[Security](/categories/security)

ucscode/local-storage
=====================

A PHP library for local data storage with optional encryption.

2.0.6(1y ago)0301MITPHPPHP &gt;=8.1

Since Jan 7Pushed 1y ago1 watchersCompare

[ Source](https://github.com/ucscode/Local-Storage)[ Packagist](https://packagist.org/packages/ucscode/local-storage)[ RSS](/packages/ucscode-local-storage/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (8)Used By (1)

Local Storage Library
=====================

[](#local-storage-library)

The Local Storage Library is a simple PHP library that provides a convenient way to store and retrieve data with optional encryption. It is designed to work similarly to `stdClass` but with the added functionality of saving and loading data to and from a file.

Installation
------------

[](#installation)

You can install the Local Storage Library using [Composer](https://getcomposer.org/). Run the following command:

```
composer require ucscode/local-storage
```

### Installation without Composer

[](#installation-without-composer)

If you prefer not to use Composer, you can manually include the Local Storage Library in your project by following these steps:

1. Clone the [Github repository](https://github.com/ucscode/local-storage) and extract the zipped content into your project directory.
2. In your PHP code, include the `LocalStorage.php` file:

```
require_once 'path/to/src/LocalStorage.php';
```

Encryption
----------

[](#encryption)

By default, the library uses gzdeflate and gzinflate for basic data compression. However, you can enhance security with OpenSSL encryption by simply providing a security key during instantiation.

Usage
-----

[](#usage)

If the instantiation file already contains LocalStorage data, the LocalStorage instance will be automatically populated with that data.

```
use Ucscode\LocalStorage\LocalStorage;

$filepath = 'path/to/storage/file.txt';

$localStorage = new LocalStorage($filepath);
```

Optionally, a secret key can be added during instantiation to enhance security.

```
$optionalSecretKey = "my_secret_key";

$localStorage = new LocalStorage($filepath, $optionalSecretKey);
```

### Creating &amp; Accessing

[](#creating--accessing)

```
$localstorage->author = "Ucscode";
$localStorage->data = [];
$localStorage->data['foundation'] = "User Synthetics";
$localStorage->data['description'] = "Save encrypted contents into local file instead of database";

$localStorage->data['foundation']; // User Synthetics
```

### Saving Data

[](#saving-data)

The data within LocalStorage will not be automatically saved unless the save method is explicitly called.

```
$localStorage->save();
```

### Retrieving All Data

[](#retrieving-all-data)

To retrieve an array of all data available in local storage, utilize the `getContext` method.

```
$localStorage->getContext(); // [author => Ucscode, data => [...]]
```

Contributing &amp; Feedback
---------------------------

[](#contributing--feedback)

If you encounter any issues, have suggestions, or want to contribute to the Local Storage Library, please open an [issue](https://github.com/ucscode/local-storage/issues) on the GitHub repository.

License
-------

[](#license)

This Local Storage Library is open-source software licensed under the [MIT license](https://opensource.org/licenses/MIT).

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance38

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~55 days

Recently: every ~31 days

Total

7

Last Release

534d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/65673b1b31e87471999a7614d107e7e061a38bf72191d149c66c1b943124e09c?d=identicon)[ucscode](/maintainers/ucscode)

---

Top Contributors

[![ucscode](https://avatars.githubusercontent.com/u/34024404?v=4)](https://github.com/ucscode "ucscode (10 commits)")

---

Tags

phpencryptionlocal storage

### Embed Badge

![Health badge](/badges/ucscode-local-storage/health.svg)

```
[![Health](https://phpackages.com/badges/ucscode-local-storage/health.svg)](https://phpackages.com/packages/ucscode-local-storage)
```

###  Alternatives

[stymiee/php-simple-encryption

The PHP Simple Encryption library is designed to simplify the process of encrypting and decrypting data while ensuring best practices are followed. By default is uses a secure encryption algorithm and generates a cryptologically strong initialization vector so developers do not need to becomes experts in encryption to securely store sensitive data.

448.0k](/packages/stymiee-php-simple-encryption)[poly-crypto/poly-crypto

High-level cryptographic functions that are interoperable between NodeJS and PHP 7.1+

127.8k1](/packages/poly-crypto-poly-crypto)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
