2017 © Pedro Peláez
 

library pocket

Little storing services

image

carlosv2/pocket

Little storing services

  • Friday, November 18, 2016
  • by carlosV2
  • Repository
  • 1 Watchers
  • 0 Stars
  • 102 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

Pocket

Little storing services, (*1)

License Build Status SensioLabsInsight, (*2)

This project aims to provide quick and easy in-file persisting capabilities., (*3)

Usage

The projec is composed by 3 main classes:, (*4)

  • ValuePocket: This class stores just a single value of any type. It requires the path of the file where the data will be persisted. Optionally, you can pass a default value that will be returned if nothing has been stored yet. For example:, (*5)

    use carlosV2\Pocket\ValuePocket;
    
    $pocket = new ValuePocket('/path/to/the/file', 42);
    $pocket->load(); // Returns: 42
    
    $pocket->save(4);
    $pocket->load(); // Returns: 4
    
  • CollectionPocket: This class stores a collection of values of any type. It requries the path of the file where the data will be persisted. For example:, (*6)

    use carlosV2\Pocket\CollectionPocket;
    
    $pocket = new CollectionPocket('/path/to/the/file');
    $pocket->add('a');
    $pocket->add(1);
    $pocket->add(true);
    
    $pocket->getValues(); // Returns: ['a', 1, true]
    
  • IndexedPocket: This class stores an indexed collection of values of any type. It requires the path of the file where the data will be persisted. For example:, (*7)

    use carlosV2\Pocket\IndexedPocket;
    
    $pocket = new IndexedPocket('/path/to/the/file');
    $pocket->add('key1', 'a');
    $pocket->add('key2', 1);
    $pocket->add('key3', true);
    
    $pocket->getValues(); // Returns: ['a', 1, true]
    $pocket->getKeys(); // Returns: ['key1', 'key2', 'key3']
    

Additionally, a manager class is provided so that a single folder path is needed. The files management is carried out by this class. Additionally, it can perform maintenance task. For example:, (*8)

use carlosV2\Pocket\PocketManager;

$manager = new PocketManager('/path/to/the/folder/');

$manager->getValuePocket(); // Returns an instance of ValuePocket
$manager->getCollectionPocket(); // Returns an instance of CollectionPocket
$manager->getIndexedPocket(); // Returns an instance of IndexedPocket

$manager->clear(); // Removes any file inside /path/to/the/folder/ folder

Install

Open a command console, enter your project directory and execute the following command to download the latest stable version of this project:, (*9)

$ composer require --dev carlosv2/pocket

This command requires you to have Composer installed globally, as explained in the installation chapter of the Composer documentation., (*10)

The Versions

18/11 2016

dev-master

9999999-dev

Little storing services

  Sources   Download

MIT

The Requires

 

The Development Requires

by Carlos Ortega

test filesystem symfony storing

18/11 2016

1.0.0

1.0.0.0

Little storing services

  Sources   Download

MIT

The Requires

 

The Development Requires

by Carlos Ortega

test filesystem symfony storing