A Symfony2 Bundle to wrap the PHP ftp extension functionality in a more "classy" way.
Require the bundle with composer:
$ composer require ijanki/ftp-bundle
Finally, enable the bundle in the kernel:
<?php
// app/AppKernel.php
public function registerBundles()
{
$bundles = [
// ...
new Ijanki\Bundle\FtpBundle\IjankiFtpBundle(),
];
}
<?php
use Ijanki\Bundle\FtpBundle\Exception\FtpException;
public function indexAction()
{
//...
try {
$ftp = $this->container->get('ijanki_ftp');
$ftp->connect($host);
$ftp->login($username, $password);
$ftp->put($destination_file, $source_file, FTP_BINARY);
} catch (FtpException $e) {
echo 'Error: ', $e->getMessage();
}
//...
}
All php ftp functions are wrapped in Ftp object:
For example:
ftp_mkdir becomes $ftp->mkdir or
ftp_put becomes $ftp->put
with the same arguments except the first one (resource $ftp_stream).
Check Ftp.php for other added methods.
Inspired by https://github.com/dg/ftp-php