Run laravel tinker command from .bat file windows

219 views Asked by At

I'm using Laravel tinker to run my script

use Spatie\Browsershot\Browsershot;
$namafile = 'foto.jpeg';
$selectorIndex = '0';
$path = storage_path().'/app/'.$namafile;
Browsershot::url('http://127.0.0.1:8000/ds_rev_daily_l2')->select('.print', $selectorIndex)->setDelay(20000)->save($path);

I want to run script above with CMD Commands After Batch Script. How can the script run from single click at .bat file? Running the script from tinker from CMD Commands After Batch Script

1

There are 1 answers

0
AmooAti On

You can use Tinker's execute option to execute the given code.

Here's a sample in bash:

php artisan tinker --execute="use \App\Models\Faq; $faq = Faq::find(1); $faq->question = 'from tinker'; $faq->save();" 

Despite this option, we can create a batch file like the one below:

@echo off
cd %userprofile%\project_dir
php artisan tinker --execute="use Spatie\Browsershot\Browsershot; $namafile = 'foto.jpeg'; $selectorIndex = '0'; $path = storage_path().'/app/'.$namafile; Browsershot::url('http://127.0.0.1:8000/ds_rev_daily_l2')->select('.print', $selectorIndex)->setDelay(20000)->save($path);"