Download the PHP package korriganmaster/lite-collection without Composer
On this page you can find all versions of the php package korriganmaster/lite-collection. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Please rate this library. Is it a good library?
Informations about the package lite-collection
LiteCollection
A lightweight PHP library for managing data collections with a persistent storage system using SQLite.
Features
- Lightweight Collection: Implements
Countable,ArrayAccess, andIteratorAggregateinterfaces - SQLite Storage: Data persistence in memory or on disk
- Two Operating Modes:
MODE_NORMAL: Uses auto-incremented keys (0, 1, 2...)MODE_ASSOCIATIVE: Uses a custom primary key
- Simple Interface: Manipulate data like a standard PHP array
Installation
Usage
Basic Example
Associative Mode with Custom Key
Persistent Disk Storage
API
LiteCollection
The LiteCollection class provides a collection interface:
count(): int: Returns the number of itemsoffsetGet($offset): mixed: Retrieves an item by its indexoffsetSet($offset, $value): void: Sets or updates an itemoffsetUnset($offset): void: Removes an itemoffsetExists($offset): bool: Checks if an item existsgetIterator(): Traversable: Returns an iterator to traverse the collection
SqliteStorage
The StorageInterface:
insert(mixed $item): void: Inserts a new itemfindById(int $id): mixed: Finds an item by its IDexists(int $id): bool: Checks if an item existsupdate(int $id, mixed $item): void: Updates an existing itemdelete(int $id): void: Deletes an itemcount(): int: Returns the number of items- Implements
Iteratorto traverse items
StorageInterface
The StorageInterface interface defines the contract for storage systems:
Storage Modes:
StorageInterface::MODE_NORMAL: Normal mode with auto-incremented keysStorageInterface::MODE_ASSOCIATIVE: Associative mode with custom primary key
Testing
The project includes unit tests using PHPUnit:
Tests cover:
LiteCollectionTest: Collection testsSqliteStorageTest: SQLite storage tests
Development
Requirements
- PHP 8.0 or higher
- SQLite3 extension
- Composer
Development Tools
Architecture
The project follows a simple architecture:
LiteCollection: Main collection classAbstractStorage: Abstract class for storage systemsSqliteStorage: SQLite storage implementationStorageInterface: Interface defining the storage contract
License
This project is licensed under the MIT License.
All versions of lite-collection with dependencies
PHP Build Version
Package Version
Requires
ext-sqlite3 Version
*
php Version >=8.0
php Version >=8.0
The package korriganmaster/lite-collection contains the following files
Loading the files please wait ...