2017 © Pedro Peláez
 

library file-system-bundle

A file system component supporting different file storage adapters.

image

partnermarketing/file-system-bundle

A file system component supporting different file storage adapters.

  • Friday, February 24, 2017
  • by BernardoSilva
  • Repository
  • 18 Watchers
  • 0 Stars
  • 8,595 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 6 Forks
  • 6 Open issues
  • 15 Versions
  • 0 % Grown

The README.md

FileSystemBundle

Build Status Scrutinizer Code Quality Code Coverage HHVM Status, (*1)

FileSystemBundle is a file system component supporting different file storage adapters., (*2)

Adapters:

Local storage

This adapter was made to be used when you want to interact with your local file system., (*3)

Config example:, (*4)

    partnermarketing_file_system.default_file_system: local_storage
    partnermarketing_file_system.config:
        local_storage:
            path: /path/to/test/directory
            url: 'http://your-project-url.dev/test'

Amazon S3

This adapter was made to be used when you want to interactive with Amazon S3 file system., (*5)

Config example:, (*6)

    partnermarketing_file_system.default_file_system: amazon_s3
    partnermarketing_file_system.config:
        amazon_s3:
            key:    your-amazon-key
            secret: your-amazon-secret
            bucket: your-bucket-name
            region: eu-west-1
            acl:    public-read # Optional parameter.

How to use

Configuration

First step is to pass the factory into where you need to use it., (*7)

# In your services.yml
    YourServiceName:
        class: Your\Namespace\Path\ServiceName
        arguments:
            fileSystemFactory:  @partnermarketing_file_system.factory

Then in your ServiceName.php file you can use the factory as you need., (*8)


namespace Your\Namespace\Path; use Partnermarketing\FileSystemBundle\Factory\FileSystemFactory; class ServiceName { private $fileSystem; public function __construct(FileSystemFactory $fileSystemFactory) { // This will build a fileSystem based on configs specified. $this->filesystem = $fileSystemFactory->build(); } }

Read a file content

$this->filesystem->read($varWithFilePath);

Write content from a file to other

// Writes the content of the $source into the $path returns the URL.
$url = $this->filesystem->write($path, $source);

Write content into a file

// Writes the $content into the $path returns the URL:
$url = $this->filesystem->writeContent($path, $content);

Delete a file

// Deletes the file $path:
$isDeleted = $this->filesystem->delete($path);

Rename a file

$isRenamed = $this->filesystem->rename($sourcePath, $targetPath);

Get files from directory

// Returns an array of files under given directory.
$filesArray = $this->filesystem->getFiles($directory = '');

Copy files from one directory to another

// Copies all files under given source directory to given target directory.
$filesArray = $this->filesystem->copyFiles($sourceDir, $targetDir);

Check if a file exist

$fileExists = $this->filesystem->exists($varWithFilePath);

Check if path is a directory

$isDirectory = $this->filesystem->isDirectory($varWithFilePath);

Gets the Absolute URL to a file

$absoluteFileUrl = $this->filesystem->getURL($path);

Copy file to temporary directory

// Copy a file to the local temporary directory, and return the full path.
$temporaryFilePath = $this->filesystem->copyToLocalTemporaryFile($path);

How to contribute

You can add more adapters or improve the existing ones., (*9)

Create a pull request and please add tests if you fix a bug or added new functionality., (*10)

Report founded issues here:, (*11)

https://github.com/partnermarketing/PartnermarketingFileSystemBundle/issues, (*12)

The Versions

24/02 2017
24/02 2017
10/02 2017
29/01 2017
29/01 2017
20/01 2017

2.0.0

2.0.0.0 https://github.com/partnermarketing/PartnermarketingFileSystemBundle

A file system component supporting different file storage adapters.

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

14/01 2016

1.2.1

1.2.1.0 https://github.com/partnermarketing/PartnermarketingFileSystemBundle

A file system component supporting different file storage adapters.

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

20/11 2015

1.2.0

1.2.0.0 https://github.com/partnermarketing/PartnermarketingFileSystemBundle

A file system component supporting different file storage adapters.

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

21/09 2015

0.2.3

0.2.3.0 https://github.com/partnermarketing/PartnermarketingFileSystemBundle

A file system component supporting different file storage adapters.

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

04/09 2015

1.1.0

1.1.0.0 https://github.com/partnermarketing/PartnermarketingFileSystemBundle

A file system component supporting different file storage adapters.

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

14/04 2015

1.0.0

1.0.0.0 https://github.com/partnermarketing/PartnermarketingFileSystemBundle

A file system component supporting different file storage adapters.

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

30/01 2015

0.2.2

0.2.2.0 https://github.com/partnermarketing/PartnermarketingFileSystemBundle

A file system component supporting different file storage adapters.

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

02/12 2014

0.2.1

0.2.1.0

A file system component supporting different file storage adapters.

  Sources   Download

The Requires

 

The Development Requires

30/11 2014

0.2.0

0.2.0.0

A file system component supporting different file storage adapters.

  Sources   Download

The Requires

 

The Development Requires