PHP code example of stk2k / file-system
1. Go to this page and download the library: Download stk2k/file-system library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once ('vendor/autoload.php' );
stk2k / file-system example snippets
use stk2k \filesystem \FileSystem ;
FileSystem::put('/path/to/file' , 'Hello, World' );
use stk2k \filesystem \FileSystem ;
FileSystem::delete('/path/to/file' );
use stk2k \filesystem \FileSystem ;
$ret = FileSystem::get('/path/to/file' );
echo $ret;
$ret = FileSystem::getAsArray('/path/to/file' );
print_r($ret);
use stk2k \filesystem \File ;
use stk2k \filesystem \FileSystem ;
$ret = FileSystem::put('/path/to/file' , 'Hello, World!' );
echo $ret->get();
$ret = FileSystem::put('/path/to/file' , ['Foo' , 'Bar' ]);
echo $ret->get();
file_put_contents('/path/to/file1' , 'Hello, World!' );
$ret = FileSystem::put('/path/to/file2' , new File('/path/to/file1' ));
echo $ret->get();
class MyStringableObject
{
public function __toString () : string
{
return 'Hello, World!' ;
}
}
$ret = FileSystem::put('/path/to/file' , new MyStringableObject());
echo $ret->get();
use stk2k \filesystem \File ;
$ret = new File('/path/to/file' );
echo $ret->get();