1. Go to this page and download the library: Download deepeloper/lib-fs 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/ */
\deepeloper\Lib\FileSystem\Tools::search(
"/path/to/dir",
0, // Flags (php://glob())
["*", ".*"], // File name patterns (php://glob())
["*", ".*"], // Subdir name patterns (php://glob())
"needle", // String to search in files, if starts with "/" processes like regular expression
function ($path, array $args)
{
// $args['path'] contains passed "/path/to/dir" ($dir)
// $args['needle'] contains passed "needle" ($needle)
$contents = file_get_contents($path);
$contents = preg_replace("/needle/", "replacement", $contents);
file_put_contents($path, $contents);
}
);
$logger = new \deepeloper\Lib\FileSystem\Logger([
'path' => "/path/to/log",
// 'maxSize' => int maxSize, // Logger::DEFAULT_MAX_SIZE by default.
// 'rotation' => int rotation, // Rotating files number, 0 means no rotation.
// 'rights' => int rights, // If set after writing to log file chmod() will be called.
]);
$logger->log("Foo");
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.