Welcome Guest, Not a member yet? Register   Sign In
FTP/SFTP in CodeIgniter
#1

[eluser]dailygrind[/eluser]
Hi,
I'm developing an application that will need to transfer files. I don't know at the moment if will be an FTP or a SFTP protocol. How do you think I should design it using CodeIgniter? Is there an SFTP class in CI?
#2

[eluser]Mauricio de Abreu Antunes[/eluser]
No, CI has no SFTP implementation.
https://github.com/ipolar/CodeIgniter-sFTP-Library


Look his lib and create your own. Smile
I can help you if you need, i would be glad to help.
#3

[eluser]dailygrind[/eluser]
Hi thanks!
My idea was to develop a wrapper class so that I can use it in this sort of way but having of course both FTP and SFTP implementation behind it.

Code:
$transfer = new Transfer();
$transfer->connect();
$transfer->upload('/local/this.txt', '/remote/this.txt');
$transfer->close();

My idea was to name methods like this

Code:
private function _ftp_connect()
private function _sftp_connect()

and call them based on a config file using __call....

Is this a good approach?
#4

[eluser]Mauricio de Abreu Antunes[/eluser]
My idea:
1 - Watch for the difference between STFP and FTP.
2 - Try to construct a lib with a parent class, reusing common methods (SFTP and FTP).

Good luck and have fun!
#5

[eluser]dailygrind[/eluser]
Thanks for the tip! Will do.
#6

[eluser]PhilTem[/eluser]
You might also wanna have a look at CI-Drivers. That's probably better fitting your needs. And in terms of the idea of drivers and libraries, a driver fits much better Wink
#7

[eluser]InsiteFX[/eluser]
This would be just right for creating a CI Driver class.

CodeIgniter User Guide - Using CodeIgniter Drivers

CodeIgniter User Guide - Creating Drivers
#8

[eluser]InsiteFX[/eluser]
LOL @PhilTem lookat post times...
#9

[eluser]Mauricio de Abreu Antunes[/eluser]
@PhilTem and @InsiteFX

Are you brothers? HAHA!

Anyway, tell me: why is CI Driver better than CI Lib?




Theme © iAndrew 2016 - Forum software by © MyBB