carlosv2/pocket 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

carlosv2/pocket

Composer 安装命令:

composer require carlosv2/pocket

包简介

Little storing services

README 文档

README

Little storing services

License Build Status SensioLabsInsight

This project aims to provide quick and easy in-file persisting capabilities.

Usage

The projec is composed by 3 main classes:

  • 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:

    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:

    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:

    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:

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:

$ composer require --dev carlosv2/pocket

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

统计信息

  • 总下载量: 126
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-11-17

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固