Download the PHP package lukaswhite/directory without Composer

On this page you can find all versions of the php package lukaswhite/directory. 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 directory

Directory

A PHP class that represents a directory on a filesystem.

With it, you can:

Creating a Instance

Simply path the full path to the directory to the constructor:

Checking it Exists

The directory needn't exist when you create an instance; use the exists() method to check that it does.

Checking it's a Directory

It might also a good idea to check that the path you provided is actually a directory, not a file.

Creating it

To create a directory, pass the path to the constructor and then call create().

By default the mode is set to 0777, but you can override this by passing it as an argument:

Alternatively, you can use createIfDoesNotExist() which, as the name suggests, will create it if it does not already exist.

This action is recusrive; i.e. it will create any necessary parent directories.

Listing Files

Call getFiles() to get a list of the files in the directory.

This will return an array with the full path to the files in the directory, excluding directories.

To include the directories:

To get all of the files in a directory including any subdirectories, pass true as the second argument:

Glob

To glob the directory:

Checking if a File Exists

To check whether a directory contains a file with a particular name:

Getting the Most Recent file

Use mostRecentFile() to get the most recently modified file.

You can use a pattern; for example to get the most recently modified text file:

To include directories, pass true as the second argument.

Getting the Total Size

To get the total size, in bytes, of a directory:

Unique Filenames

Suppose you allow users to upload an avatar, which you store in a directory named avatars with the filename in the form username.png.

That works fine initially, but causes problems if a user uploads a replacement.

To get around that, ensureUniqueFilename() will return a similar filename that doesn't exist.

For example, if joebloggs.png exists, it'll return joebloggs-1.png. A subsequent call will return joebloggs-2.png, and so on.

The method returns the filename only, but you can get the full path with fullPathToFile().

For example:

Creating a File

To create an empty file in a directory:

To create a file, providing its contents:

Copying a File Into a Directory

To copy a file into the directory:

Deleting a Directory

Use with caution!

To delete a directory, its contents and it's sub-directories, simply call delete().


All versions of directory with dependencies

PHP Build Version
Package Version
No informations.
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 lukaswhite/directory contains the following files

Loading the files please wait ....