PHPackages                             mychaelstyle/php-utils - 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. [File &amp; Storage](/categories/file-storage)
4. /
5. mychaelstyle/php-utils

ActiveLibrary[File &amp; Storage](/categories/file-storage)

mychaelstyle/php-utils
======================

library for web apps

0.1.2(12y ago)0313Apache2PHP

Since Aug 2Pushed 12y ago1 watchersCompare

[ Source](https://github.com/mychaelstyle/php-utils)[ Packagist](https://packagist.org/packages/mychaelstyle/php-utils)[ RSS](/packages/mychaelstyle-php-utils/feed)WikiDiscussions master Synced 4w ago

READMEChangelogDependencies (3)Versions (8)Used By (0)

mychaelstyle/php-utils
======================

[](#mychaelstylephp-utils)

mychaelstyle/php-utils is imple utilities for php 5.

Outline
=======

[](#outline)

1. Storage version 0.1.0 ... easy access to online storages.
2. Datastore version 0.1.0 ... easy access to key value stores.
3. queue\\Factory version 0.1.0 ... easy access to queue service.

mychaelstyle\\Storage
=====================

[](#mychaelstylestorage)

Storage is an uploading utility class to online or offline storage services. You can transfer and read, write files like local files only simple configurations.

Storageはローカルファイルを扱い様な感覚で様々なストレージサービスにファイルを保存するライブラリです。 簡単な設定だけで同時に複数のストレージにファイルをアップロードすることもできます

#### Supported storage

[](#supported-storage)

- Local file system
- Amazon S3 (require AWS SDK files)
- Mysql

#### Usage

[](#usage)

You can read and write as local file.

ローカルファイルを扱うように読み書きできます。

```
$dsn = 'local:///home/hoge/storage';
$options = array('permission'=>0644,'permission_folder'=>0755)
$storage = new mychaelstyle\Storage($dsn,$options);

// you can open and write,
$file = $storage->createFile('/foo/var.txt');
$file->open('w');
$file->write("Hello mychaelstyle\\Storage!\n");
$file->close();

// you can read
$file = $storage->createFile('/foo/hoge.txt');
$file->open('r');
$str = $file->fgets();
$file->close();

// import from local file
$file = $storage->createFile('/foo/boo.txt');
$file->import('/home/hoge/boo.txt');

// file_get_contents
$file = $storage->createFile('/foo/example.txt');
$string = $file->getContents();

// file_put_contents
$file = $storage->createFile('/foo/me.txt');
$file->putContents("My name is Masanori Nakashima.\n");

```

#### simple transaction support.

[](#simple-transaction-support)

You can upload after all tasks are success. but this transaction don't support exclusive.

すべてのタスクが完了してからアップロードを確定するシンプルなトランザクション機能があります。 ただしこのトランザクションは現在は排他ロックをサポートしていません。

```
$dsn = 'amazon_aws://TOKYO/my_bucket';
$options = array(
		'acl'      => AmazonS3::ACL_PUBLIC,
		'curlopts' => array(CURLOPT_SSL_VERIFYPEER => false)
);
$storage = new mychaelstyle\Storage($dsn,$options,false);
try {
  $file1 = $storage->createFile('/foo/me.txt');
  $file1->putContents("My name is Masanori Nakashima.\n");

  $file2 = $storage->createFile('/foo/you.txt');
  $file2->putContents("What's your name?\n");

  $storage->commit();
} catch(Exception $e){
  $storage->rollback();
}

```

#### support upload some storages at once.

[](#support-upload-some-storages-at-once)

You can upload to some storage at once, do followings.

複数のオンラインストレージに同時に同じファイルをアップロードすることができます。

```
// create new instance
$dsn = 'local:///home/hoge/storage';
$options = array('permission'=>0644,'permission_folder'=>0755)
$storage = new mychaelstyle\Storage($dsn,$options);
// add a provider
$dsn = 'amazon_aws://TOKYO/my_bucket';
$options = array(
		'acl'      => AmazonS3::ACL_PUBLIC,
		'curlopts' => array(CURLOPT_SSL_VERIFYPEER => false)
);
$storage->addProvider($dsn,$options);
// put contents
$storage->putContents('/my/foo.txt', 'This is test contents!');

```

Amazon S3
---------

[](#amazon-s3)

### DSN

[](#dsn)

```
amazon_s3://[your aws region]/[your bucket name]

```

### Initialize Options

[](#initialize-options)

- key ... Amazon Web Services Key.
- secret ... Amazon Web Services Secret.
- default\_cache\_config ... see the aws php sdk document.
- certificate\_autority ... see the aws php sdk document.
- curlopts ... curl options. array.
- acl ... acl. see the aws php sdk.
- contentType ... content-type

### File upload options

[](#file-upload-options)

You can use all options of AWS SDK Amazon S3 file options. see the AWS PHP SDK.

Mysql
-----

[](#mysql)

### DSN

[](#dsn-1)

```
mysql://[host]:[port]/[database]/[table]
mysql://[host]:[port]/[database]/[table]?uri=[field name for uri]&contents=[field name for contents]

```

### Initialize options

[](#initialize-options-1)

- user ... mysql connect user
- pass ... mysql connect password

How to develop a provider plugin
================================

[](#how-to-develop-a-provider-plugin)

You can develop anothe storage provider plugin, only extends from mychaelstyle\\storage\\Provider class.

for example,

```
class GoogleDrive extends \mychaelstyle\storage\Provider {
  public function connect($dsn,$options=array()){
    // ... something to do for connection
  }
  public function get($uri,$pathto=null){
    // something to do,
    // but if $pathto is not null, you should save the file to the path
    // after getting the file from the uri.
  }
  public function put($path,$to,$options=array()){
    // something to do,
  }
  public function remove($uri){
    // something to do,
  }
}

```

Testing
-------

[](#testing)

You should set following envs for Tests of AWS plougins.

- AWS\_KEY
- AWS\_SECRET\_KEY
- AWS\_REGION
- AWS\_S3\_BUCKET

e.g. for .\*rc

```
AWS_KEY="Your aws key"
AWS_SECRET_KEY="Your aws secret key"
AWS_REGION="TOKYO"
AWS_S3_BUCKET="your-bucket-name"
export AWS_KEY AWS_SECRET_KEY AWS_REGION AWS_S3_BUCKET

```

###  Health Score

27

—

LowBetter than 47% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 97% 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 ~11 days

Total

3

Last Release

4690d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/917007a7be969d6f159eec9d8a985d5c062f05275f09f2f56a361acabedf23c3?d=identicon)[Masanori Nakashima](/maintainers/Masanori%20Nakashima)

---

Top Contributors

[![mychaelstyle](https://avatars.githubusercontent.com/u/1973992?v=4)](https://github.com/mychaelstyle "mychaelstyle (64 commits)")[![masanori-nakashima](https://avatars.githubusercontent.com/u/4110370?v=4)](https://github.com/masanori-nakashima "masanori-nakashima (2 commits)")

---

Tags

amazons3awsSNS

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/mychaelstyle-php-utils/health.svg)

```
[![Health](https://phpackages.com/badges/mychaelstyle-php-utils/health.svg)](https://phpackages.com/packages/mychaelstyle-php-utils)
```

###  Alternatives

[aws/aws-sdk-php-laravel

A simple Laravel 9/10/11/12/13 service provider for including the AWS SDK for PHP.

1.7k37.3M83](/packages/aws-aws-sdk-php-laravel)[league/flysystem-aws-s3-v3

AWS S3 filesystem adapter for Flysystem.

1.7k277.8M972](/packages/league-flysystem-aws-s3-v3)[aws/aws-sdk-php-resources

A resource-oriented API for interacting with AWS services

1361.9M13](/packages/aws-aws-sdk-php-resources)[vinelab/cdn

Content Delivery Network (CDN) Package for Laravel

217242.9k1](/packages/vinelab-cdn)[aws/aws-sdk-php-zf2

Zend Framework 2 Module that allows easy integration the AWS SDK for PHP

1041.0M5](/packages/aws-aws-sdk-php-zf2)[publiux/laravelcdn

Content Delivery Network (CDN) Package for Laravel

155233.5k](/packages/publiux-laravelcdn)

PHPackages © 2026

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