Tinker is a REPL for the Laravel PHP framework.
Questions tagged [tinker]
136 questions
34
votes
2 answers
PHP Artisan Tinker crashing from any command
I haven't had this problem before, but my php artisan tinker crashes from issuing any command - and leaves no logs whatsoever on what is causing the crash.
project4 $ php artisan tinker
Psy Shell v0.9.9 (PHP 7.3.0 — cli) by Justin Hileman
>>> use…

G.S.
- 502
- 8
- 16
24
votes
1 answer
Auth not working in Laravel Tinker
From within Tinker I am trying to:
>>> Auth::loginUsingId(12);
=> false
>>> Auth::user();
=> null
>>> Auth::attempt(['email' => 'my@email.com']);
=> false
I am guessing that since Auth typically uses session data, and maybe sessions don't work with…

ajon
- 7,868
- 11
- 48
- 86
18
votes
2 answers
Laravel 5.6 Tinker Class '...' not found in Psy Shell code on line 1
I'm trying to make a simple class in a fresh-installed Laravel. For this I have created a folder app/Convert and put the php-file there. The class looks like this:

Timkolm
- 185
- 1
- 1
- 7
17
votes
4 answers
Unable to use Laravel Factory in Tinker
I am unable Model Factory in Laravel Tinker.
//ItemFactory.php
class ItemFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = Item::class;
/**
*…

Lizesh Shakya
- 2,482
- 2
- 18
- 42
14
votes
4 answers
Laravel Tinker - Arrow keys not working in shell
I'm getting started with a Laravel 5 project and trying to run some experiments using 'php artisan tinker' (psy shell), but I'm running into some weirdness. In the tinker/psy shell, pressing any of the arrow keys is printing character literals to…

Sean Fraser
- 342
- 3
- 14
11
votes
1 answer
PHP Artisan Tinker not working with Laravel 5.4 and PHP 7.0.1
I just added tinker to my Laravel project 5.4.
When I try to run:
php artisan tinker
I am getting following error:
PHP Warning: Uncaught ErrorException: require(/home/abdullah/php_apps/website): failed to open stream: Success in…

AMBasra
- 969
- 8
- 24
9
votes
1 answer
Can I run a command in Laravel Tinker within just one entry in the CLI?
I want to start using tinker to debug functions much faster. The issue is that for every change I need to stop and start tinker again.
I'm hoping I can use something like you have with mysql; you can start mysql and do your queries like that, but…

iosifv
- 1,153
- 1
- 10
- 26
7
votes
1 answer
Laravel artisan tinker from Amazon Linux 2 (Elastic Beanstalk)
I used to execute tinker on previous Amazon AMI by using this command :
sudo -E -u webapp php artisan tinker
Now I am using PHP 7.4 on Amazon Linux 2 and when I execute the above command, I get this error :
Unable to create PsySH runtime directory.…

Marc
- 1,350
- 2
- 11
- 29
6
votes
3 answers
How to write in new line with laravel tinker
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…

rook99
- 1,034
- 10
- 34
6
votes
3 answers
How to get all records which meet a Criteria in Laravel Tinker?
I can get the first user, who is an admin in Laravel's tinker using the following command:
$adminUser = App\User::where('is_admin',true)->first();
How do I get all the users which meet this where criteria?

Devdatta Tengshe
- 4,015
- 10
- 46
- 59
6
votes
3 answers
How to specify Tinker to use a different database connection?
I have two database connections. One for my application and another for testing.
In my ..\config\database.php
'mysql' => [
'driver' => 'mysql',
'host' => env('DB_HOST', 'localhost'),
'database' …

Lizesh Shakya
- 2,482
- 2
- 18
- 42
5
votes
1 answer
Laravel - "artisan tinker" -> mkdir(): Permission denied
I have been searching for hours now but cannot find a solution even though there are similar problems out there.
I am trying to run php artisan tinker on a fresh laravel installation with user webmaster (who is owner of the project directory demo)…

pixelmusik
- 510
- 5
- 19
4
votes
3 answers
PHP Artisan tinker Class 'XdgBaseDir\Xdg' not found
I encountered and error when running php artisan tinker in my current project. I tried to create a new project using laravel new projectname but the same error occurs when running php artisan tinker.
This is the error that occurs.
````Class…

Pseudoman21
- 51
- 5
4
votes
3 answers
How to fix tinker color text?
I'm using Visual Studio Code to coding but recently i have strange problem how can i fix that?
When i enter php artisan tinker the tinker text isn't as always i remember the color was blue but now its white.
also after use php artisan migrate and…
user10242523
3
votes
2 answers
Laravel "artisan tinker" stops with a colon (:)
When a lot of text is printed (example User::all()), old tinker v2.7.1 prints all data. The new tinker stops with a colon (:). Is there a way to return the old behavior?

Mantas D
- 3,993
- 3
- 26
- 26