PHP FTP Wrapper Bundle
This is a Symfony2 bundle to wrap the FTP Component, (*1)
Installation
composer.json, (*2)
{
"require": {
"touki/ftp-bundle": "dev-master"
}
}
Then run, (*3)
$ composer install touki/ftp-bundle
Then you must add the bundle in your AppKernel.php
, (*4)
Configuration
The default configuration is as follows, (*5)
touki_ftp:
host: localhost # Remote server name
username: anonymous # Username to connect with
password: guest # Password to connect with
port: 21 # Port to connect to
secured: false # Whether to connect with SSL or not
Service list
For the standard usage of the component, please read the documentation, (*6)
<?php
$container->get('ftp.connection');
?>
Holds the connection to the server.
It opens it by default., (*7)
<?php
$container->get('ftp.wrapper');
?>
The simple FTP wrapper., (*8)
<?php
$container->get('ftp.manager');
?>
The filesystem manager, (*9)
<?php
$container->get('ftp');
?>
The main FTP Class, (*10)
Adding a downloader
To add a custom downloader, you need to create a downloader which implements the interfaces as follows, (*11)
Then in your services.yml
, create a new service which adds the ftp.downloader
tag, (*12)
services:
acme_foo.mydownloader:
class: Acme\FooBundle\Downloader\MyDownloader
tags:
- { name: ftp.downloader, prepend: false } # Set prepend to true to prepend the downloader
Adding an uploader
To add a custom uploader, you need to create a uploader which implements the interfaces as follows, (*13)
Then in your services.yml
, create a new service which adds the ftp.uploader
tag, (*14)
services:
acme_foo.myuploader:
class: Acme\FooBundle\Uploader\MyUploader
tags:
- { name: ftp.uploader, prepend: false } # Set prepend to true to prepend the uploader