Level 50
i would tryLog::debug() instead and examine the log file.
i thought you were talking about jobs, sorry, edited
1 like
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hey guys i want to debug a job handle using the command line i'am using php artisan schedule:run
i want to debug $db below using the command line example = dd($db);
public function handle()
{
$data = DB::table('users')
->select('id','name')
->where('db_name', null)
->limit(10);
foreach ( $data as $user ) {
$name = preg_replace("/[^a-zA-Z0-9]/", "", $user->name);
$name = substr($name, 0, 8);
$new_dbname = $name + $user->id;
}
// IF NOT EXISTS!!
$db = DB::statement("CREATE DATABASE IF NOT EXISTS $new_dbname;");
dd($db);
if ( $db !== null ) {
DB::table('users')->whereNull('db_name',$new_dbname)->update([
'db_name' => DB::raw("CONCAT(name, '_', id)")
]);
}
}
@bobdebower in answer to your question, if you want to output to the command line you should use
$this->info('foo'); // green text
$this->error('bar'); // red text
$this->line('baz'); // plain text
https://laravel.com/docs/8.x/artisan#writing-output
or for debug var_dump() or var_export()
Please or to participate in this conversation.