PHPackages                             idlesign/ist-yii-cfile - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [File &amp; Storage](/categories/file-storage)
4. /
5. idlesign/ist-yii-cfile

ActiveLibrary[File &amp; Storage](/categories/file-storage)

idlesign/ist-yii-cfile
======================

CFile provides means to manipulate filesystem objects both from Yii and standalone

v1.0.0(12y ago)5628.8k22[2 issues](https://github.com/idlesign/ist-yii-cfile/issues)MITPHPPHP &gt;=5.1.0

Since Jul 5Pushed 8y ago9 watchersCompare

[ Source](https://github.com/idlesign/ist-yii-cfile)[ Packagist](https://packagist.org/packages/idlesign/ist-yii-cfile)[ Docs](https://github.com/idlesign/ist-yii-cfile)[ RSS](/packages/idlesign-ist-yii-cfile/feed)WikiDiscussions master Synced 3w ago

READMEChangelogDependenciesVersions (2)Used By (0)

ist-yii-cfile
=============

[](#ist-yii-cfile)

Warning

**This project is no longer maintained. Thank you for watching us.**

What's that
-----------

[](#whats-that)

**ist-yii-cfile** is an extension for Yii Framework, bundling commonly used functions for filesystem objects (files and directories) manipulation.

This extension can also operate in standalone mode, i.e. without Yii.

Quick overview
--------------

[](#quick-overview)

- Properties
    - exists
    - isdir
    - isfile
    - isempty
    - isuploaded
    - readable
    - writeable
    - realpath
    - relativepath
    - basename (+setter)
    - filename (+setter)
    - dirname
    - extension (+setter)
    - mimeType
    - timeModified
    - size
    - owner (+setter)
    - group (+setter)
    - permissions (+setter)
- Methods
    - create
    - createdir
    - purge
    - contents
    - copy
    - rename/move
    - send/download
    - delete

Requirements
------------

[](#requirements)

- PHP 5.1+ and Yii 1.0 or above to use as Yii extension.
- PHP 5.1+ to use without Yii.

Installation
------------

[](#installation)

- For Yii: extract extension files under protected/extensions/file.
- Without Yii: extract extension files into a directory of choise.

Usage
-----

[](#usage)

**To use with Yii Framework:**

- Introduce CFile to Yii.
- Add definition to CWebApplication config file (main.php)

```
'components'=>array(
    ...
    'file'=>array(
        'class'=>'application.extensions.file.CFile',
    ),
    ...
),
```

- Now you can access CFile properties and methods as follows:

```
$myfile = Yii::app()->file->set('files/test.txt', true);
/*
 * We use set() method to link new CFile object to our file. First set() parameter
 * - 'files/test.txt' - is the file path (here we supply relative path wich
 * is automatically converted into real file path such as '/var/www/htdocs/files/test.txt').
 * Second set() parameter - true - tells CFile to get all file properties at the very
 * beginning (it could be omitted if we don't need all of them).
 */

// $myfile now contains CFile object, let's see what do we got there.

var_dump($myfile);  // You may dump object to see all its properties,

echo $myfile->size;  // or get property,

$myfile->permissions = 755;  // or set property,
$mynewfile = $myfile->copy('test2.txt');  // or manipulate file somehow, e.g. copy.

// Please see CFile methods for actions available.

/*
 * Now $mynewfile contains new CFile object.
 * In this example file 'test2.txt' created in the same directory as our first 'test.txt' file.
 */

// The following is also valid.
if (Yii::app()->file->set('files/test3.txt')->exists) {
    echo 'Bingo-bongo!';
} else {
    echo 'No-no-no.';
}

/*
 * Since 0.5 you can manipulate uploaded files (through CUploadedFile Yii class).
 *
 * Let's suppose that we have the following form in our html:
 *
 *
 *
 *
 *
 *
 * After the form is submitted we can handle uploaded file as usual.
 */
$uploaded = Yii::app()->file->set('myupload');

// Let's copy newly uploaded file into 'files' directory with its original name.
$newfile = $uploaded->copy('files/' . $uploaded->basename);

/*
 * Since 0.6 you can use Yii path aliases.
 * See http://www.yiiframework.com/doc/guide/basics.namespace for information about path aliases.
 *
 * Now let's get the contents of the directory where CFile resides
 * (supposing that it is in Yii extensions path in the 'file' subdirectory).
 */
$cfileDir = Yii::app()->file->set('ext.file');

print_r($cfileDir->contents);

/*
 * Directory contents filtering was also introduced in 0.6.
 *
 * Futher we get all php files from $cfileDir mentioned above.
 * We do not need all the decendants (recursion) so we supply 'false' as the first parameter
 * for getContents() method.
 * The second parameter describes filter, i.e. let me see only 'php' files.
 * You can supply an array of rules (eg. array('php', 'txt')).
 * NB: Moreover you can define perl regular expressions as rules.
 */
print_r($cfileDir->getContents(false, 'php'));

/*
 * Since 0.8 you can boost up file downloads.
 * Feature requires 'x-sendfile' header support from server (eg. Apache with mod_xsendfile
 * or lighttpd).
 * If CFile::download() second parameter ('serverHandled') is set to True file download uses
 * server internals.
 */
$myfile->download('myfastfile.txt', true);
```

- The other way to use this class is to import it into Yii:

```
Yii::import('application.extensions.file.CFile');

if (CFile::set('files/test3.txt')->exists) {
    echo 'Bingo-bongo!';
} else {
    echo 'No-no-no.';
}
```

**To use without Yii**

Simply import CFileHelper.php when needed and use CFileHelper::get() to get CFile object for a filesystem resource.

```
$cf_file = CFileHelper::get('files/test.txt');  // $cf_cile now contains CFile object, use it as required.
$cf_file->copy('mycopy.txt');
```

Further reading
---------------

[](#further-reading)

Detailed information about class properties and methods could be found in CFile.php source code, do not hesitate to digg into it.

###  Health Score

36

—

LowBetter than 79% of packages

Maintenance19

Infrequent updates — may be unmaintained

Popularity37

Limited adoption so far

Community19

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 92.4% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

4739d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/effa592876b1f9bc8d8c41df17c598c2b14157d84d2c4ce0c31bd17b20c078f9?d=identicon)[idlesign](/maintainers/idlesign)

---

Top Contributors

[![idlesign](https://avatars.githubusercontent.com/u/145644?v=4)](https://github.com/idlesign "idlesign (61 commits)")[![Kolyunya](https://avatars.githubusercontent.com/u/2682768?v=4)](https://github.com/Kolyunya "Kolyunya (3 commits)")[![Atorich](https://avatars.githubusercontent.com/u/944546?v=4)](https://github.com/Atorich "Atorich (1 commits)")[![Cruiser13](https://avatars.githubusercontent.com/u/2771909?v=4)](https://github.com/Cruiser13 "Cruiser13 (1 commits)")

---

Tags

file-managementphpyiifilesystemfilesyii

### Embed Badge

![Health badge](/badges/idlesign-ist-yii-cfile/health.svg)

```
[![Health](https://phpackages.com/badges/idlesign-ist-yii-cfile/health.svg)](https://phpackages.com/packages/idlesign-ist-yii-cfile)
```

###  Alternatives

[league/flysystem

File storage abstraction for PHP

13.6k665.7M2.4k](/packages/league-flysystem)[league/flysystem-aws-s3-v3

AWS S3 filesystem adapter for Flysystem.

1.7k277.8M961](/packages/league-flysystem-aws-s3-v3)[league/flysystem-local

Local filesystem adapter for Flysystem.

224254.9M71](/packages/league-flysystem-local)[league/flysystem-memory

In-memory filesystem adapter for Flysystem.

8535.9M248](/packages/league-flysystem-memory)[creocoder/yii2-flysystem

The flysystem extension for the Yii framework

2861.7M63](/packages/creocoder-yii2-flysystem)[league/flysystem-sftp-v3

SFTP filesystem adapter for Flysystem.

6133.1M132](/packages/league-flysystem-sftp-v3)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
