Download the PHP package spoova/enlist without Composer
On this page you can find all versions of the php package spoova/enlist. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download spoova/enlist
More information about spoova/enlist
Files in spoova/enlist
Informations about the package enlist
Enlist Package
This is a spoova framework package for listing or renaming files in a directory. It can be used to rename file names and file extensions. While renaming file extensions can break the functionality of a file, some specific files extensions can be easily modified. Renaming files extensions that can be easily broken should be avoided. At most times, this class may be used to change extension of image files or text-related file. Although, some file extensions can be easily modified, yet it does not serve as converter for such files. In the case where a converter is needed, a converter tool should be employed.
Including the Enlist class
Run the command below in the terminal to require the package
Initializing the Enlist class
In your sample php file include the vendor/autoload.php file and import the Enlist class
Set a file directory
In order to use the Enlist package, the source directory must first be be specified
Check if file directory is valid
We can check if the source directory supplied is valid through the method
List files in directory
The code below will list all files in a directory except hidden files
List files in directory having jpg extension
The code below will list all files with .jpg files in a directory
List hidden files in directory
The code below will list all files in specified directory having only extension name without any file name
List hidden files in directory and files having png extension only
The code below will list all .png files in the source directory along with hidden files
List all files in directory including hidden
The code below will list all files including hidden files in a directory
Renaming Files in directory
Rename all file extensions in a directory to png except hidden files
The result of a renaming can also be obtained by suppling a second argument to function
Rename only .jpg file extensions in a directory to png extension
Rename only .jpg file names in a directory with serial numbering
Files can be renamed with serial numbers starting from a specific number using the method
Renaming all file names in a directory with serial numbering with a named prefix can be done using both the and methods
Spaces in file names can be replaced with another character through the method.
Smart url format can be applied to file name. This will remove special characters from file names
The method can be used to prevent from actively renaming files. Only the expected output result will be seen as array list if no error occurs
Getting Data
The method can be used to fetch the resulting data when any of the , or method is used.
Handling Errors
Errors can be returned as text if debug mode is not turned on
Errors can also be fetched by turning debug mode on without throwing errors. In order to do this the method must be turned on before is called. Finally the method will return all backtraces where error occured. Note that the or method are only executed if the specified source url is valid.
Debugs can also be fetched by supplying a referenced variable into the method.
Throwing errors can be enabled when the debug mode is enabled. This can be done by supplying an argument of on the method.
The debug method can also help to keep track of errors when turned off
Working with session
In certain situations where files are renamed in a way that is not desired or one desires to reverse back to the previous file names, enlist supports the reversal of changes made to files only if there is no overiding of files. To reverse back to previous names, a session must be actively defined with the method and a unique key where the most recent changes are stored. If no session was started earlier the method will start a new session of its own. Once the enlist session name is defined, the method can be applied to revert changes.
Allow Enlist to revert recent changes from session storage
Session names can also be specified from the session storage. Reversals will be made only if the old filename still exists in the specified directory. Also, when a reversal has been made, the stored session urls will be cleared out.
Characters and their functions
The list below describes arguments and their functions
-
- All hidden files only
-
- All files except hidden
-
- All files including hidden files
-
- All jpg file extensions only
-
- All specified file extensions only
Good Practices
It is always good to set the renaming to view mode first to check how the final result of a list of renamed files will be before proceeding to rename the item to avoid issues like merging of conflicts which can lead to loss of file.