调试拉拉维尔作业
我正在尝试调试Laravel中队列中的作业,但没有成功。我想将输出打印到控制台中。例如您如何在其他任何地方使用。dd()
<?php
namespace App\Jobs;
use App\Image;
use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
class ProcessImage implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
protected $image;
/**
* Attempt the job a maximum of twice
*
* @var int
*/
public $tries = 2;
/**
* Create a new job instance.
*
* @return void
*/
public function __construct(Image $image)
{
$this->image = $image;
}
/**
* Execute the job.
*
* @return void
*/
public function handle()
{
// set paths for standard and thumbnail size images
$image = public_path("assets" . DIRECTORY_SEPARATOR . $this->image->original);
$product_id = $this->image->id;
$product_path = public_path("assets" . DIRECTORY_SEPARATOR . "images" . DIRECTORY_SEPARATOR .
"products" . DIRECTORY_SEPARATOR . $product_id);
$thumbnail_path = $product_path . DIRECTORY_SEPARATOR . "thumbnail";
if(!is_dir($product_path))
mkdir($product_path);
if(!is_dir($thumbnail_path))
mkdir($thumbnail_path);
// Resize and save the standard image
$standard = \Image::make($image)->resize(450, 450, function($constraint)
{
$constraint->aspectRatio();
})->save($product_path);
dd($standard);
}
}