Skip to content

Instantly share code, notes, and snippets.

@coulterpeterson
Last active November 22, 2019 00:18
Show Gist options
  • Save coulterpeterson/6733ae1926e94a6119d4c45fead4e7b6 to your computer and use it in GitHub Desktop.
Save coulterpeterson/6733ae1926e94a6119d4c45fead4e7b6 to your computer and use it in GitHub Desktop.
#Laravel connect to SMTP using Flysystem #PHP
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Flysystem;
use League\Flysystem\Filesystem;
use League\Flysystem\Sftp\SftpAdapter;
class PagesController extends Controller
{
public function connectAndList(){
$host = request('host');
$username = request('username');
$password = request('password');
$filesystem = new Filesystem(new SftpAdapter([
'host' => $host,
'port' => 22,
'username' => $username,
'password' => $password,
'timeout' => 10,
]));
return view('welcome', [
'data' => $filesystem->listContents('/public_html/', false),
]);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment