Laravel 为 SSH 登录远程服务器并运行命令提供了一种简单的方式,允许你轻松创建运行在远程服务器上的 Artisan 任务。SSH 门面类(facade)提供了连接远程服务器和运行命令的访问入口。配置文件位于 app/config/remote.php,该文件包含了配置远程连接所需的所有选项。connections 数组包含了一个以名称作为键的服务器列表。
SSH::into('staging')->put($localFile, $remotePath); SSH::into('staging')->putString('Foo', $remotePath); 显示远程日志的末尾几行Laravel 提供了一个有用的命令用来查看任何远程连接服务器上的 laravel.log 文件的末尾几行内容。只需使用 Artisan 命令 tail 并指定你想要查看日志的远程连接的名称即可:...
* Execute the command. * * @return void */ publicfunctionhandle() { // Handle the logic to purchase the podcast... event(newPodcastWasPurchased($this->user,$this->podcast)); } } Laravel 的基底控制器使用了新的DispatchesCommandstrait,让你可以简单的派发命令运行: ...
首先通过 artisan 文件调用到 laravel/framework/src/Illuminate/Foundation/Console/Kernel.php 文件,在这个 Kernel.php 中的 handle() 方法中会调用 symfony/console/Application.php ,接着进入 laravel/framework/src/Illuminate/Console/Command.php 中执行 execute() 方法,通过回调的方式调用我们自定义的那个 handle(...
* Execute the consolecommand. */ publicfunctionhandle() {echo"开始执行命令:"; } } 注意: signature是从命令行执行的命令名,而不是文件名, 从命令行执行时,只能使用在此处指定的命令名 二,从命令行运行 root@lhdpc:/data/api# runuser -u www-data php artisan app:index-all-command开始执行命令: ...
* * @return void */ public function __construct(User $user, Podcast $podcast) { $this->user = $user; $this->podcast = $podcast; } /** * Execute the command. * * @return void */ public function handle() { // Handle the logic to purchase the podcast... event(new PodcastWas...
3SSH::into('staging')->putString($remotePath,'Foo'); Tailing Remote Logs Laravel includes a helpful command for tailing thelaravel.logfiles on any of your remote connections. Simply use thetailArtisan command and specify the name of the remote connection you would like to tail: ...
* * @return void */ public function __construct(User $user, Podcast $podcast) { $this->user = $user; $this->podcast = $podcast; } /** * Execute the command. * * @return void */ public function handle() { // Handle the logic to purchase the podcast... event(new PodcastWas...
在以前,开发者需要为每一个需要调度的任务编写一个 Cron 条目,这是很让人头疼的事。你的任务调度不在源码控制中,你必须使用 SSH 登录到服务器然后添加这些 Cron 条目。Laravel 命令调度器允许你流式而又不失优雅地在 Laravel 中定义命令调度,并且服务器上只需要一个 Cron 条目即可。任务调度定义在 app/Console/...
Schedule::command('emails:send')->daily()->skip(function(){returntrue;}); When using chainedwhenmethods, the scheduled command will only execute if allwhenconditions returntrue. Environment Constraints Theenvironmentsmethod may be used to execute tasks only on the given environments (as defined by...