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

v4.0.0 2023-04-21 18:57 UTC

This package is auto-updated.

Last update: 2024-10-26 10:42:42 UTC


README

A Symfony2 Bundle to wrap the PHP ftp extension functionality in a more "classy" way.

Latest Stable Version Build Status Total Downloads License

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