Connect FTP with Lumen

2

I'm doing an API with the Lumen framework and I would like to upload files of the application to an FTP only that I have not seen any documentation about it and I wanted to know if there is any documentation on how to upload files to an FTP with Lumen .

Thank you.

    
asked by Jose Yeste 28.11.2017 в 21:30
source

1 answer

1

This function is not integrated in the default lumen, as if it were in laravel, you have to install the Flysystem library, you can verify the process in this tutorial

The steps would be:

  • Install using composer with the command: composer require graham-campbell / flysystem.
  • Require the adapter for ftp league / flysystem-sftp

  • Register the service provider in the bootstrap / app.php file adding this line:

  

$ app-> register (GrahamCampbell \ Flysystem \ FlysystemServiceProvider :: class);

  • Copy the flysystem.php configuration file from the package. That is to copy the file that is in the directory vendor / graham-campbell / flysystem / config / flysystem.php to the folder
    config.

  • In the ftp section, you enter your access data:

  

'ftp' = > [               'driver' = > 'ftp',               'host' = > 'ftp.example.com',               'port' = > twenty-one,               'username' = > 'your-username',               'password' = > 'your-password',]

  • Use it in your controller:
  

use GrahamCampbell \ Flysystem \ Facades \ Flysystem;

     

Flysystem :: connection ('ftp') - > read ('FileUpload.txt');

    
answered by 19.03.2018 / 15:37
source