2017 © Pedro Peláez
 

library file

image

asgard/file

  • Saturday, August 19, 2017
  • by leyou
  • Repository
  • 1 Watchers
  • 1 Stars
  • 2,424 Installations
  • PHP
  • 5 Dependents
  • 1 Suggesters
  • 0 Forks
  • 0 Open issues
  • 5 Versions
  • 0 % Grown

The README.md

File

Build Status, (*1)

File is a package to work with the file system and it provides a class to manipulate files as objects., (*2)

, (*3)

Installation

If you are working on an Asgard project you don't need to install this library as it is already part of the standard libraries., (*4)

composer require asgard/file 0.*

, (*5)

FileSystem

$mode

When a method takes a parameter $mode, you can use different values:, (*6)

$mode = \Asgard\File\FileSystem::OVERRIDE; #override existing files
$mode = \Asgard\File\FileSystem::RENAME; #rename new files
$mode = \Asgard\File\FileSystem::IGNORE; #ignore existing files
$mode = \Asgard\File\FileSystem::MERGEDIR; #merge directories
$mode = \Asgard\File\FileSystem::MERGEDIR | \Asgard\File\FileSystem::OVERRIDE; #merge directories but override existing files
$mode = \Asgard\File\FileSystem::MERGEDIR | \Asgard\File\FileSystem::RENAME; #merge directories but rename new files
$mode = \Asgard\File\FileSystem::MERGEDIR | \Asgard\File\FileSystem::IGNORE; #merge directories but ignore existing files

It defaults to OVERRIDE., (*7)

Methods

Get relative path from a file to another:, (*8)

\Asgard\File\FileSystem::relativeTo($from, $to);

Get a new filename if the existing one is already taken:, (*9)

$filename = \Asgard\File\FileSystem::getNewFilename($filename);

Rename a file or directory:, (*10)

$path = \Asgard\File\FileSystem::rename($src, $dst, $mode=null);

returns the new path if successful, otherwise false., (*11)

Copy a file or directory:, (*12)

$path = \Asgard\File\FileSystem::copy($src, $dst, $mode=null);

returns the new path if successful, otherwise false., (*13)

Delete a file or directory:, (*14)

\Asgard\File\FileSystem::delete($path);

returns true is successful, otherwise false., (*15)

Create a new directory:, (*16)

\Asgard\File\FileSystem::mkdir($path);

returns true is successful, otherwise false., (*17)

Write content into a file:, (*18)

\Asgard\File\FileSystem::write($path, $content, $mode=null, $append=false);

returns true is successful, otherwise false., (*19)

, (*20)

File

Instance:, (*21)

$file = new \Asgard\File\File('/path/to/file.txt');

Set source:, (*22)

$file->setSrc('/path/to/another/file.txt');

Set file name:, (*23)

$file->setName('file2.txt');

Get file name:, (*24)

$file->getName();

Check if the file was just uploaded:, (*25)

$file->isUploaded();

Get the file size in bytes:, (*26)

$file->size();

Get the file type:, (*27)

$file->type();

Get the file extension:, (*28)

$file->extension();

Check if the file exists:, (*29)

$file->exists();

Get the file source:, (*30)

$file->src();

Get the relative path to another file or directory:, (*31)

$file->relativeTo('/another/file.jpg');

Move the to another directory:, (*32)

$file->moveToDir('/a/dir/', $mode=null);

Check if the file is in a directory, (*33)

$file->isIn('/a/dir/');

Check if the file is at a specific path:, (*34)

$file->isAt('/path/to/file.txt');

Rename the file:, (*35)

$file->rename('/anoter/path/to/file.txt', $mode=null);

Delete the file:, (*36)

$file->delete();

Copy the file:, (*37)

$file->copy('/path/to/copy.txt', $mode=null);

Contributing

Please submit all issues and pull requests to the asgardphp/asgard repository., (*38)

License

The Asgard framework is open-sourced software licensed under the MIT license, (*39)

The Versions

19/08 2017

dev-master

9999999-dev

  Sources   Download

MIT

The Requires

  • php >=5.5.0

 

The Development Requires

by Michel Hognerud

13/05 2016

v0.3.1

0.3.1.0

  Sources   Download

MIT

The Requires

  • php >=5.5.0

 

by Michel Hognerud

12/05 2016

v0.3.0

0.3.0.0

  Sources   Download

MIT

The Requires

  • php >=5.5.0

 

by Michel Hognerud

13/06 2015

v0.2.0

0.2.0.0

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

by Michel Hognerud

09/09 2014

v0.1.0

0.1.0.0

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

by Michel Hognerud