PHP Classes

PHP CDN Upload Functions: Send and receive files to CDN servers using SFTP

Recommend this page to a friend!
  Info   View files Documentation   View files View files (3)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2022-04-03 (19 days ago) RSS 2.0 feedNot yet rated by the usersTotal: 32 All time: 10,449 This week: 163Up
Version License PHP version Categories
cdn-functions 1.0The PHP License5Networking, PHP 5, Files and Folders
Description Author

This package can send and receive files to CDN servers using SFTP.

It provides a sub-class for the CakePHP framework component class that can connect to the secure FTP server of a CDN server to transfer files.

Currently, it can:

- Send a given local file to a remote path in the CDN server

- Delete a file with a remote path in the CDN server

- Download all files from a given remote path in the CDN server to a local directory

Picture of Kushal Pogul
Name: Kushal Pogul <contact>
Classes: 2 packages by
Country: India India
Innovation award
Innovation award
Nominee: 1x

Details

CdnFunctions plugin

Build Status License

About plugin

CdnFunctions plugin contains 3 important functions which allows a file to copy on CDN, Delete a file from CDN & Downloading all files from directory of CDN.

Requirements

1) CakePHP 3 2) PHP 5.4 3) SSH2 4) CDN Server

Including Plugin

??In bootstrap.php file of application, add below line to include plugin into application Plugin::load('CdnFunctions', ['autoload' => true]);

??In Controller file, add below line in initialize() function to load plugin in controller. $this->loadComponent('CdnFunctions.Cdn' );

Configuring CDN

??In Component file of plugin, specify details of CDN.

??File: \plugins\CdnFunctions\src\Controller\Component\CdnComponent.php

var $SFTP_HOST = ?host-name';
var $SFTP_PORT = ?port_no?;
var $SFTP_USER = ?user-name?;
var $SFTP_PASS = 'password';

Functions in Plugin

1) sendFile($src, $dst) : ??This function sends file to CDN server.

??Usage: ??In controller file of your application,

   $src = 'file_name.jpg';  		// file that is to be copied to CDN
   
   $dst = '/path/on/cdn/file_name.jpg';	// path on CDN where file is to be copied
   
   $this->Cdn->sendFile($src, $dst);  

2) deleteFile($file): ??This Function delete file from CDN Server.

??Usage: ??In controller file of your application,

   $this->Cdn->deleteFile('/path/on/cdn/file_name.jpg');	
   

3) downloadAllFiles($localDir, $remoteDir): ??This function downloads all files present in directory of CDN.

??Usage: ??In controller file of your application,

    $localDir  = '/path/on/local/'; // path on local where all files are to be copied

?? $remoteDir = '/path/on/cdn/'; // path on cdn from where we dowload all files


  	$this->Cdn->downloadAllFiles($localDir, $remoteDir);
  Files folder image Files  
File Role Description
Files folder imageplugins (1 directory)
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file README.md Doc. Documentation

  Files folder image Files  /  plugins  
File Role Description
Files folder imageCdnFunctions (1 directory)

  Files folder image Files  /  plugins  /  CdnFunctions  
File Role Description
Files folder imagesrc (1 directory)

  Files folder image Files  /  plugins  /  CdnFunctions  /  src  
File Role Description
Files folder imageController (1 directory)

  Files folder image Files  /  plugins  /  CdnFunctions  /  src  /  Controller  
File Role Description
Files folder imageComponent (1 file)

  Files folder image Files  /  plugins  /  CdnFunctions  /  src  /  Controller  /  Component  
File Role Description
  Plain text file CdnComponent.php Class Class source

 Version Control Unique User Downloads Download Rankings  
 100%
Total:32
This week:0
All time:10,449
This week:163Up
For more information send a message to info at phpclasses dot org.