Download the PHP package modevsome/mofilesmanager without Composer
On this page you can find all versions of the php package modevsome/mofilesmanager. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package mofilesmanager
moFilesManager is a small library for handling files and folders more easier in PHP.
The library provide two objects, one for handling files and one for handling folders.
Required Configuration
php: >=7.0.0
Fileinfo PHP extension
How to use
Installation
The better way for adding moFilesManager to your application is to use Composer by launching it in your dev environment, here's the URL of the Packagist page : https://packagist.org/packages/modevsome/mofilesmanager
You can also download the last release.
Tests
Once moFilesManager is added into your application, don't hesitate to play some tests for checking the basic functions of the library. Open you command line tool and execute the following command :
You can ask a log file of the tests by adding ths param : -log
Basic usage
You can read the method summary below to find out all the features.
IMPORTANTS ADVICES 
- write and test your script in a local dev environment
- avoid using moFilesManager for very complex files tree, with too many files and nested subfolder, it prevent crash caused by too much recursivity, "out of time" or "out of memory" execution (for example, dispatch your task if you have a high quantity of files to process)
- don't forget to remove the "tests" folder before pushing your application to your production environment
moFilesManager\Folder methodes summary
Create a Folder instance
This method return an instance of the Folder class. The path is optionnal at this step, and can be changed later.
Change the path
This method change the path value of the Folder object. This method is fluent, it return the current object.
Create the folder
This method create the folder on the disk. This method return TRUE in case of success, else FALSE.
Copy the folder
This method recursively duplicat the current folder at the provided location defined in the required $copy_path param. All the content of the folder will be duplicated, including files and subfolders.
The boolean param $replace is optionnal. If the param is equal to TRUE, the folder we be replaced if it already exist, if tthe param is equal to FALSE, the existing folder will be not replaced. By default the param is equal to TRUE.
This method return TRUE in case of success, else FALSE.
Rename the folder
This method change the name of the current folder. The provided $new_name should not be a path, just a folder name.
The boolean param $replace is optionnal. If the param is equal to TRUE, the folder we be replaced if it already exist, if tthe param is equal to FALSE, the existing folder will be not replaced. By default the param is equal to TRUE.
This method return TRUE in case of success, else FALSE.
Move the folder
This method duplicat the current folder at the provided location defined in the required $copy_path param. All the content of the folder will be moved, including files and subfolders.
The boolean param $replace is optionnal. If the param is equal to TRUE, the folder we be replaced if it already exist, if tthe param is equal to FALSE, the existing folder will be not replaced. By default the param is equal to TRUE.
This method return TRUE in case of success, else FALSE.
Drain the folder
This method recursively remove all items contained into the folder.
A rollback function minimise the impact of eventual errors occurred during the process.
This method return TRUE in case of success, else FALSE.
Delete the folder
This method delete the folder, even if there's files or subfolders contained in the folder.
A rollback function minimise the impact of eventual errors occurred during the process.
This method return TRUE in case of success, else FALSE.
Make a Zip archive of the folder
All the items will be recursively added in the archive.
@param string $archive_name : The path of the zip file that will be made. Default : The folder parent path
@param boolean $replace : True to replace the current file if it already exist. Default : TRUE
@param array $options : An array containing some options : 'compression_method', 'compression_level'
This method return TRUE in case of success, else FALSE.
Extract an archive zip into the the current folder
The path of the zip file must be provided throw the param $archive_path.
The boolean param $replace is optionnal. If the param is equal to TRUE, the folder we be replaced if it already exist, if the param is equal to FALSE, the existing folder will be not replaced. By default the param is equal to TRUE.
A rollback function minimise the impact of eventual errors occurred during the process.
This method return TRUE in case of success, else FALSE.
IMPORTANT : The extracted archive need to be outside the target folder.
moFilesManager\File methodes summary
Create a File instance
This method return an instance of the File class. The path is optionnal at this step, and can be changed later.
Change the path
This method change the path value of the File object. This method is fluent, it return the current object.
Get the current file content
Return the file content as a string.
Set the current file content
This method change the content of the file.
The content of the file is NOT saved as long as the method write() is not called.
This method is fluent, it return the current object.
Add content to the current file
This method Append or Prepend the provided content to the current content string.
The content of the file is NOT saved as long as the method write() is not called.
This method is fluent, it return the current object.
Create or replace the current file on the disk
This method save the current file on the disk.
The boolean param $replace is optionnal. If the param is equal to TRUE, the file we be replaced if it already exist, if tthe param is equal to FALSE, the existing file will be not replaced. By default the param is equal to TRUE.
This method return TRUE in case of success, else FALSE.
Copy the current file
This method duplicat the current at the provided location defined in the required $copy_path param.
The boolean param $replace is optionnal. If the param is equal to TRUE, the file we be replaced if it already exist, if tthe param is equal to FALSE, the existing file will be not replaced. By default the param is equal to TRUE.
This method return TRUE in case of success, else FALSE.
Rename the current file
This method change the name of the current file, BUT it does not move the file. The provided $new_name should not be a path, just a file name.
The boolean param $replace is optionnal. If the param is equal to TRUE, the file we be replaced if it already exist, if tthe param is equal to FALSE, the existing file will be not replaced. By default the param is equal to TRUE.
This method return TRUE in case of success, else FALSE.
Move the current file
This method move the current file at the provided location defined in the required $new_path param.
The boolean param $replace is optionnal. If the param is equal to TRUE, the file we be replaced if it already exist, if tthe param is equal to FALSE, the existing file will be not replaced. By default the param is equal to TRUE.
This method return TRUE in case of success, else FALSE.
Delete the current file
This method delete the current file. This method return TRUE in case of success, else FALSE.
Upload a file
This method upload a file.
@param $tmp_name : The file tmp_name (required). It can be found in the associeted row of the superglobal $_FILES.
@param $replace : TRUE to replace the current file if it already exist. Default : TRUE
@param $allowed_types : An array which contain one or more file type that will be accepted, if this param if empty, all types will be accepted.
@param $max_size : The allowed maximum file size (must be provided in BYTES).
This method return TRUE in case of success, else FALSE.
Get the FileStream
DO NOT FORGET TO CLOSE the STREAM with FCLOSE!
@param string $fopenMode
@param boolean $forceFolderCreation
@return mixed Returns a file pointer resource on success, or FALSE on failure
@since 1.1.4
moFilesManager\moFilesManager methodes summary
The following methods must be called statically.
Enable/Disable debuging
By default debuging is disabled, set debuging to TRUE if you want to use the trace log
Return nothing (void)
Get the current debuging state
Get all recorded traces
Return an array containing all recorded traces during the several process
Get the last recorded trace
Return a string which contain the last logged content
Rebuild and Secure a given path by removing illegitimate directory separator
Return a string which contain the cleaned path