All Projects → yii2mod → yii2-ftp

yii2mod / yii2-ftp

Licence: MIT license
FTP Client for Yii2

Programming Languages

PHP
23972 projects - #3 most used programming language

Projects that are alternatives of or similar to yii2-ftp

Yii2 Angular Boilerplate
Yii2 REST API + Angular10 Boilerplate (Frontend/Backend)
Stars: ✭ 194 (+506.25%)
Mutual labels:  yii2
Cms
Craft is a flexible, user-friendly CMS for creating custom digital experiences on the web and beyond.
Stars: ✭ 2,713 (+8378.13%)
Mutual labels:  yii2
yii2-lets-talk
With this extension you can open chat with someone in popular messengers using the link on your website.
Stars: ✭ 15 (-53.12%)
Mutual labels:  yii2
Search Engine Rank
🐘根据网站关键词,获取网站在各大搜索引擎(百度、360、搜狗)的排名情况,有利于网站seo
Stars: ✭ 197 (+515.63%)
Mutual labels:  yii2
Yii2 Translate Manager
Translation Manager
Stars: ✭ 221 (+590.63%)
Mutual labels:  yii2
Yii2 Imperavi Widget
Imperavi Redactor widget for Yii 2
Stars: ✭ 250 (+681.25%)
Mutual labels:  yii2
Ar Softdelete
Soft delete behavior for ActiveRecord
Stars: ✭ 188 (+487.5%)
Mutual labels:  yii2
yii2-deferred-tasks
Yii2 extension for handling deferred tasks (background cron jobs)
Stars: ✭ 11 (-65.62%)
Mutual labels:  yii2
Galaxy
The whole galaxy system, you can customize it base on your requirements.
Stars: ✭ 230 (+618.75%)
Mutual labels:  yii2
php-ftp-client
📦 Provides helper classes and methods to manage FTP files in an OOP way.
Stars: ✭ 81 (+153.13%)
Mutual labels:  ftp-client
Yii2
Yii 2: The Fast, Secure and Professional PHP Framework
Stars: ✭ 13,852 (+43187.5%)
Mutual labels:  yii2
Yii2 Webshell
Web shell allows to run yii console commands using a browser
Stars: ✭ 220 (+587.5%)
Mutual labels:  yii2
Yii2 Usuario
Highly customizable and extensible user management, authentication, and authorization Yii2 extension
Stars: ✭ 251 (+684.38%)
Mutual labels:  yii2
Yii2 Bootstrap4
Yii 2 Bootstrap 4 Extension
Stars: ✭ 204 (+537.5%)
Mutual labels:  yii2
yii2-admin-theme
基于Yii2+layui的后台框架模板,实现了完善的RBAC权限控制
Stars: ✭ 87 (+171.88%)
Mutual labels:  yii2
Yii2 Tech
Yii2 通用后台管理系统
Stars: ✭ 193 (+503.13%)
Mutual labels:  yii2
Yii2 Apidoc
Yii 2 apidoc extension.
Stars: ✭ 236 (+637.5%)
Mutual labels:  yii2
yii2-uuid
UUID Helper and validator for Yii 2
Stars: ✭ 33 (+3.13%)
Mutual labels:  yii2
termscp
🖥 A feature rich terminal UI file transfer and explorer with support for SCP/SFTP/FTP/S3
Stars: ✭ 707 (+2109.38%)
Mutual labels:  ftp-client
install
basic script for project installation
Stars: ✭ 17 (-46.87%)
Mutual labels:  yii2

FTP Client for Yii 2


Latest Stable Version Total Downloads License

yii2-ftp is a fork of Nicolab/php-ftp-client v1.2.0

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require --prefer-dist yii2mod/yii2-ftp "*"

or add

"yii2mod/yii2-ftp": "*"

to the require section of your composer.json.

Getting Started

Connect to a server FTP :

$ftp = new \yii2mod\ftp\FtpClient();
$host = 'ftp.example.com';
$ftp->connect($host);
$ftp->login($login, $password);

OR

Connect to a server FTP via SSL (on port 22 or other port) :

$ftp = new \yii2mod\ftp\FtpClient();
$host = 'ftp.example.com';
$ftp->connect($host, true, 22);
$ftp->login($login, $password);

Note: The connection is implicitly closed at the end of script execution (when the object is destroyed). Therefore it is unnecessary to call $ftp->close(), except for an explicit re-connection.

Usage

Upload all files and all directories is easy :

// upload with the BINARY mode
$ftp->putAll($source_directory, $target_directory);

// Is equal to
$ftp->putAll($source_directory, $target_directory, FTP_BINARY);

// or upload with the ASCII mode
$ftp->putAll($source_directory, $target_directory, FTP_ASCII);

Note : FTP_ASCII and FTP_BINARY are predefined PHP internal constants.

Get a directory size :

// size of the current directory
$size = $ftp->dirSize();

// size of a given directory
$size = $ftp->dirSize('/path/of/directory');

Count the items in a directory :

// count in the current directory
$total = $ftp->count();

// count in a given directory
$total = $ftp->count('/path/of/directory');

// count only the "files" in the current directory
$total_file = $ftp->count('.', 'file');

// count only the "files" in a given directory
$total_file = $ftp->count('/path/of/directory', 'file');

// count only the "directories" in a given directory
$total_dir = $ftp->count('/path/of/directory', 'directory');

// count only the "symbolic links" in a given directory
$total_link = $ftp->count('/path/of/directory', 'link');

Detailed list of all files and directories :

// scan the current directory and returns the details of each item
$items = $ftp->scanDir();

// scan the current directory (recursive) and returns the details of each item
var_dump($ftp->scanDir('.', true));

Result:

'directory#www' =>
    array (size=10)
      'permissions' => string 'drwx---r-x' (length=10)
      'number'      => string '3' (length=1)
      'owner'       => string '32385' (length=5)
      'group'       => string 'users' (length=5)
      'size'        => string '5' (length=1)
      'month'       => string 'Nov' (length=3)
      'day'         => string '24' (length=2)
      'time'        => string '17:25' (length=5)
      'name'        => string 'www' (length=3)
      'type'        => string 'directory' (length=9)

  'link#www/index.html' =>
    array (size=11)
      'permissions' => string 'lrwxrwxrwx' (length=10)
      'number'      => string '1' (length=1)
      'owner'       => string '0' (length=1)
      'group'       => string 'users' (length=5)
      'size'        => string '38' (length=2)
      'month'       => string 'Nov' (length=3)
      'day'         => string '16' (length=2)
      'time'        => string '14:57' (length=5)
      'name'        => string 'index.html' (length=10)
      'type'        => string 'link' (length=4)
      'target'      => string '/var/www/shared/index.html' (length=26)

'file#www/README' =>
    array (size=10)
      'permissions' => string '-rw----r--' (length=10)
      'number'      => string '1' (length=1)
      'owner'       => string '32385' (length=5)
      'group'       => string 'users' (length=5)
      'size'        => string '0' (length=1)
      'month'       => string 'Nov' (length=3)
      'day'         => string '24' (length=2)
      'time'        => string '17:25' (length=5)
      'name'        => string 'README' (length=6)
      'type'        => string 'file' (length=4)

All FTP PHP functions are supported and some improved :

// Requests execution of a command on the FTP server
$ftp->exec($command);

// Turns passive mode on or off
$ftp->pasv(true);

// Set permissions on a file via FTP
$ftp->chmod('0777', 'file.php');

// Removes a directory
$ftp->rmdir('path/of/directory/to/remove');

// Removes a directory (recursive)
$ftp->rmdir('path/of/directory/to/remove', true);

// Creates a directory
$ftp->mkdir('path/of/directory/to/create');

// Creates a directory (recursive),
// creates automaticaly the sub directory if not exist
$ftp->mkdir('path/of/directory/to/create', true);

// and more ...

Get the help information of remote FTP server :

var_dump($ftp->help());

Result :

array (size=6)
  0 => string '214-The following SITE commands are recognized' (length=46)
  1 => string ' ALIAS' (length=6)
  2 => string ' CHMOD' (length=6)
  3 => string ' IDLE' (length=5)
  4 => string ' UTIME' (length=6)
  5 => string '214 Pure-FTPd - http://pureftpd.org/' (length=36)

Note : The result depend of FTP server.

Support us

Does your business depend on our contributions? Reach out and support us on Patreon. All pledges will be dedicated to allocating workforce on maintenance and new awesome stuff.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].