1.0.0
2017-10-30 22:09 UTC
This package is auto-updated.
Last update: 2025-06-04 18:22:48 UTC
README
Basic Files library for PHP
Install
composer require ivandelabeldad/files
Usage
Creating and deleting Files
$file = new File("location/file.txt");
$file->createIfNotExists();
$file->delete();
Working with text files
$file = new FileText("location/file.txt");
$file->writeLine("First line.");
$file->writeLine("Second line.");
// First line.
echo $file->readFirstLine();
// Second line.
echo $file->readLastLine();
// First line.
// Second line.
echo $file->readContent();
// First line.
// Second line.
foreach($file->iterator() as $key => $line) {
echo $key . ' -> ' . $line;
}
Working with CSV files
$file = new FileTextCSV("location/file.csv");
// Without indexes
$content = $file->readContentArray(false);
// Using indexes there are two ways
// First way
$file->setIndexes([
"name",
"lastname",
]);
$content = $file->readContentArray();
// Second way
$file->useFirstLineAsIndexes();
$content = $file->readContentArray();
License
The API Rackian is open-sourced software licensed under the MIT LICENSE