PHP code example of lazyeight / ditesto

1. Go to this page and download the library: Download lazyeight/ditesto 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');

/* Start to develop here. Best regards https://php-download.com/ */

    

lazyeight / ditesto example snippets


$file = '/home/user/text-file.txt';
$fileSystem = new FileSystemHandler($file);
$textFile = new TextFile($file); 

(new FileReader($textFile, $fileSystem))->readFile();
echo $textFile; // prints all file content

$textFile = new TextFile($file); 
$fileSystem = new FileSystemHandler($file);
(new FileReader($textFile, $fileSystem))->readFile());

foreach ($textFile as $line) {
   echo $line;
}

$textFile[] = new Line('Adding a new line');
$textFile[0] = new Line('Changing an existent line');
echo count($textFile); // prints total of lines
echo $textFile[1]; // prints only the second line 

$textFile = new TextFile($file); 
$fileSystem = new FileSystemHandler($file);
(new FileWriter($textFile, $fileSystem))->writeFile();