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 (1)    
Ratings Unique User Downloads Download Rankings
Not yet rated by the usersTotal: 53 All time: 10,597 This week: 206Up
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

Innovation Award
PHP Programming Innovation award nominee
April 2022
Number 6
A Content Delivery Network (CDN) is a service that allows off-loading the service of pages and other Web site resources to a network of third-party servers.

Those servers can be geographically closer to the users of a site, thus making the service of those site pages faster for those users.

This package can perform several operations to store and retrieve files stored in CDN servers directly. It makes it easier for developers to manage content stored in CDN servers from the Web sites they developed.

Manuel Lemos
Picture of Kushal Pogul
Name: Kushal Pogul <contact>
Classes: 2 packages by
Country: India India
Age: ???
All time rank: 3850262 in India India
Week rank: 270 Up22 in India India Up
Innovation award
Innovation award
Nominee: 1x

Documentation

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:53
This week:0
All time:10,597
This week:206Up