Download the PHP package studio24/rotate without Composer

On this page you can find all versions of the php package studio24/rotate. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package rotate

Rotate

Simple file rotation utility which rotates and removes old files or folders, useful where you cannot use logrotate (e.g. a Windows system) or you want to rotate or delete files based on a timestamp or date contained in the filename.

Installation

Usage

You can use Rotate in two modes: rotate (renames files and removes oldest files) or delete (deletes files according to a pattern).

Import at the top of your PHP script via:

Setting the filename format to match

Both Rotate and Delete pass in the filename pattern you want to match for in the constructor or via the setFilenameFormat() method. This can be used to match a single file, files matching a pattern, or files with a datetime within the filename pattern.

Rotate only works on files. Delete can also delete folders and recursively deletes any child files in that folder.

Matches on leaf elements

Please note files are matched on the last leaf element. All files in the parent folder are scanned, files (and folders for Delete) are checked to see whether they match the specified pattern.

For example passing path/to/*.log will search for all files ending .log in the folder path/to.

Filename patterns

The following patterns are supported when matching files or folders:

Datetime formats

For datetime formats, any date format supported by DateTime::createFromFormat is allowed excluding the Timezone identifier e and whitespace and separator characters.

Deleting folders recursively

You can also delete folders and all child files that match. This is, however, dangerous so by default no folders can be deleted. You need to explicitly add folder paths that are safe to delete via Delete::addSafeRecursiveDeletePath($path). When using this function you need to use the full absolute path. Use realpath() to expand full paths if you need to.

For example, if you want to delete all folders in /var/www/test/staging/data/logs/ that are 1+ months old:

The above code would allow you to delete folders within /var/www/test/staging/data/logs/ only.

Rotate

Rotate log files in a similar manner to logrotate.

The following example rotates the file debug.log, this renames debug.log to debug.log.1, debug.log.1 to debug.log.2, debug.log.2 to debug.log.3 and so on. It keeps 10 copies, so it deletes debug.log.10 and renames debug.log.9 to debug.log.10.

How many copies to keep

Rotate keeps 10 copies of files by default, you can change this via:

Rotated based on filesize

You can only rotate files when they reach a certain filesize, rather than automatically rotate each time the $rotate->run() method is run.

Delete

Deletes files based on modification time, datetime in the filename, or based on a custom callback function.

Time-based

Deletes files based on the modification time. For example, to delete all JPG files in a folder over 3 months old:

The deleteByFileModifiedDate() method accepts either a valid DateInterval object or a relative date format as specified on Relative Formats.

Time format in filename

Deletes files based on the datetime in the filename. For example, to delete all order logfiles with a date in their filename over 3 months old:

Based on a custom callback

Deletes files based on a custom callback function, this is useful if you need to perform more complex code to assess whether a file should be deleted. For example, to delete all image files called 1000.jpg and below:

DirectoryIterator

The callback function must accept one parameter $file, which is of type \studio24\Rotate\DirectoryIterator.

This iterator has the following methods in addition to the normal SPL DirectoryIterator.

License

The MIT License (MIT). Please see License File for more information.

Credits


All versions of rotate with dependencies

PHP Build Version
Package Version
Requires php Version >=5.6.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package studio24/rotate contains the following files

Loading the files please wait ....