ijanki / ftp-bundle
A Symfony2 Bundle to wrap the PHP ftp extension functionality in a more classy way.
Installs: 624 636
Dependents: 0
Suggesters: 0
Security: 0
Stars: 22
Watchers: 6
Forks: 10
Type:symfony-bundle
Requires
- php: >=7.1
- symfony/config: *
- symfony/dependency-injection: *
- symfony/http-kernel: *
Requires (Dev)
- phpunit/phpunit: ~7.0
README
A Symfony2 Bundle to wrap the PHP ftp extension functionality in a more "classy" way.
Installation
Step 1: Install the bundle
Require the bundle with composer:
$ composer require ijanki/ftp-bundle
Step 2: Enable the bundle
Finally, enable the bundle in the kernel:
<?php // app/AppKernel.php public function registerBundles() { $bundles = [ // ... new Ijanki\Bundle\FtpBundle\IjankiFtpBundle(), ]; }
Usage
<?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.
Credits
Inspired by https://github.com/dg/ftp-php