How to write in new line with laravel tinker
Asked Answered
S

4

7

How can I break to a new line using laravel tinker?

So instead of: $users = User::all(); foreach($users as $user) {echo $user->email;}

I want to be able to write it as follows:

$users = User::all();

foreach($users as $user) {
   echo $user->email;
}

Is it possible?

Sea answered 1/5, 2020 at 12:14 Comment(3)
I just tried it and opening a curly brace { changes the terminal from >>> to ... and only executes the block when I put in a } so... yes it works. You really should try these things out first. That's the whole point of tinkeringSericeous
@Sericeous I did try it before posting my question, and it doesn't change the terminal to ...Sea
Ok, never mind I understand what you mean now. I should write { at first and then hit Enter. I searched about this before posting my question but didn't find any info... Thank you.Sea
S
8

Pipe your code into tinker i.e.:

cat yourcode.php | php artisan tinker

I think this might be the closest you'll get to what you want in the current version.

Salivation answered 12/3, 2021 at 12:19 Comment(0)
F
0

You can start a code block with { hit enter and then paste in your code, and close the block with } to execute it.

(I was today years old when I figured this out!)

Formation answered 1/8 at 10:37 Comment(0)
P
-1

You can break line using "\n".

Example:

$users = User::all();

foreach($users as $user) {
    echo $user->email . "\n";
}

OBS: Your "\n" needs to be inside a DOUBLE QUOTES

Pau answered 23/7, 2020 at 15:6 Comment(1)
this does not answer the question. This is about tinker, not phpGwyn
M
-1

You can write code multiple line Windows User: Ctrl + Enter

Moralist answered 26/8, 2021 at 14:27 Comment(1)
This doesnt work, it submits the line.Inflexion

© 2022 - 2024 — McMap. All rights reserved.