Laravel Custom Helpers, Facades, and Testing Fakes
Let’s consider that we want to create a custom helper named SSH. This helper is going to connect to a remote server via ssh and execute some commands. Commands Since we might have many commands, I would create an interface first. // app/Commands/Command.php namespace App\SSHCommands; use App\Contracts\SSHCommand; interface Command { public function content(); } And then an example command. // app/Commands/DirectoryListCommand.php namespace App\SSHCommands; use App\Contracts\SSHCommand; class DirectoryListCommand implements Command { public function content() { return "ls -la"; } } Helper Alright....