Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Bahjaat's avatar
Level 26

php artisan tinker throws Parse error (unexpected T_PAAMAYIM_NEKUDOTAYIM)

Somewhere lost today. Already cleared the vendor folder and updated packages one after another. Also removed a couple of packages. Nothing helped.

How to debug this?

php artisan tinker

>>> \URL::to('test');
PHP Parse error: Syntax error, unexpected T_PAAMAYIM_NEKUDOTAYIM, expecting '(' on line 1

>>> \App\User::first();
PHP Parse error: Syntax error, unexpected T_PAAMAYIM_NEKUDOTAYIM, expecting '(' on line 1
0 likes
12 replies
automica's avatar

@bahjaat

T_PAAMAYIM_NEKUDOTAYIM error often relates to a missing double colon or double quote.

::

do you have the rest of what is on line 1 in your error. Is there more of an error in your logs?

Bahjaat's avatar
Level 26

No errors in application. Weird isn’t it?

automica's avatar

@bahjaat you might also be worth clearing your composer cache

composer clearcache

delete your vendor packages, and then run

composer install

that will download brand new copies of your vendor packages rather than loading them from the cache again. That should resolve any issue with the vendor packages.

1 like
Bahjaat's avatar
Level 26

I'm a bit further. When I remove "darkaonline/l5-swagger": "^7.0" from composer.json tinker is working again. Added the package to the 'don't discover' part of the composer.json. Didn't mather.

How can I debug what tinker is doing/loading?

automica's avatar

@bahjaat have you checked that package’s GitHub page for any issues with the version of Laravel you are running?

I would also check through any recent code changes you’ve made In your application, back to the last time you last ran tinker

Bahjaat's avatar
Level 26

Found out tinker can also have -vvv argument. php artisan tinker -vvv

Psy Shell v0.10.4 (PHP 7.3.22 — cli) by Justin Hileman
>>> \URL::to('test')
PHP Parse error: Syntax error, unexpected T_PAAMAYIM_NEKUDOTAYIM, expecting '(' on line 1
--
 () at vendor/psy/psysh/src/Exception/ParseErrorException.php:40
 Psy\Exception\ParseErrorException::fromParseError() at vendor/psy/psysh/src/CodeCleaner.php:294
 Psy\CodeCleaner->parse() at vendor/psy/psysh/src/CodeCleaner.php:221
 Psy\CodeCleaner->clean() at vendor/psy/psysh/src/Shell.php:829
 Psy\Shell->addCode() at vendor/psy/psysh/src/Shell.php:521
 Psy\Shell->getInput() at vendor/psy/psysh/src/ExecutionLoopClosure.php:40
 Psy\{closure}() at vendor/psy/psysh/src/ExecutionClosure.php:96
 Psy\ExecutionClosure->execute() at vendor/psy/psysh/src/Shell.php:370
 Psy\Shell->doInteractiveRun() at vendor/psy/psysh/src/Shell.php:341
 Psy\Shell->doRun() at vendor/symfony/console/Application.php:140
 Symfony\Component\Console\Application->run() at vendor/psy/psysh/src/Shell.php:316
 Psy\Shell->run() at vendor/laravel/tinker/src/Console/TinkerCommand.php:81
 Laravel\Tinker\Console\TinkerCommand->handle() at n/a:n/a
 call_user_func_array() at vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:37
 Illuminate\Container\BoundMethod::Illuminate\Container\{closure}() at vendor/laravel/framework/src/Illuminate/Container/Util.php:37
 Illuminate\Container\Util::unwrapIfClosure() at vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:95
 Illuminate\Container\BoundMethod::callBoundMethod() at vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:39
 Illuminate\Container\BoundMethod::call() at vendor/laravel/framework/src/Illuminate/Container/Container.php:596
 Illuminate\Container\Container->call() at vendor/laravel/framework/src/Illuminate/Console/Command.php:134
 Illuminate\Console\Command->execute() at vendor/symfony/console/Command/Command.php:258
 Symfony\Component\Console\Command\Command->run() at vendor/laravel/framework/src/Illuminate/Console/Command.php:121
 Illuminate\Console\Command->run() at vendor/symfony/console/Application.php:916
 Symfony\Component\Console\Application->doRunCommand() at vendor/symfony/console/Application.php:264
 Symfony\Component\Console\Application->doRun() at vendor/symfony/console/Application.php:140
 Symfony\Component\Console\Application->run() at vendor/laravel/framework/src/Illuminate/Console/Application.php:93
 Illuminate\Console\Application->run() at vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php:129
 Illuminate\Foundation\Console\Kernel->handle() at artisan:37

Package is still in my composer.json

Bahjaat's avatar
Level 26

composer update seems to fixed it (after a couple of days)

1 like
automica's avatar

@bahjaat maybe something that got broken in your composer cache?

glad its been solved though

rexb's avatar

I encountered this too after switching from Unix to Windows There's no issue in UNIX

PS D:\www\backend> php artisan tinker -vvv Psy Shell v0.11.9 (PHP 8.1.12 — cli) by Justin Hileman

\App\Models\User:first()

PARSE ERROR PHP Parse error: Syntax error, unexpected ':' in vendor\psy\psysh\src\Exception\ParseErrorException.php on line 40.

-- () at vendor\psy\psysh\src\Exception\ParseErrorException.php:40 Psy\Exception\ParseErrorException::fromParseError() at vendor\psy\psysh\src\CodeCleaner.php:340 Psy\CodeCleaner->parse() at vendor\psy\psysh\src\CodeCleaner.php:267 Psy\CodeCleaner->clean() at vendor\psy\psysh\src\Shell.php:866 Psy\Shell->addCode() at vendor\psy\psysh\src\Shell.php:549 Psy\Shell->getInput() at vendor\psy\psysh\src\ExecutionLoopClosure.php:40 Psy{closure}() at vendor\psy\psysh\src\ExecutionClosure.php:89 Psy\ExecutionClosure->execute() at vendor\psy\psysh\src\Shell.php:395 Psy\Shell->doInteractiveRun() at vendor\psy\psysh\src\Shell.php:366 Psy\Shell->doRun() at vendor\symfony\console\Application.php:171 Symfony\Component\Console\Application->run() at vendor\psy\psysh\src\Shell.php:341 Psy\Shell->run() at vendor\laravel\tinker\src\Console\TinkerCommand.php:85 Laravel\Tinker\Console\TinkerCommand->handle() at vendor\laravel\framework\src\Illuminate\Container\BoundMethod.php:36 Illuminate\Container\BoundMethod::Illuminate\Container{closure}() at vendor\laravel\framework\src\Illuminate\Container\Util.php:40 Illuminate\Container\Util::unwrapIfClosure() at vendor\laravel\framework\src\Illuminate\Container\BoundMethod.php:93 Illuminate\Container\BoundMethod::callBoundMethod() at vendor\laravel\framework\src\Illuminate\Container\BoundMethod.php:37 Illuminate\Container\BoundMethod::call() at vendor\laravel\framework\src\Illuminate\Container\Container.php:653 Illuminate\Container\Container->call() at vendor\laravel\framework\src\Illuminate\Console\Command.php:136 Illuminate\Console\Command->execute() at vendor\symfony\console\Command\Command.php:298 Symfony\Component\Console\Command\Command->run() at vendor\laravel\framework\src\Illuminate\Console\Command.php:121 Illuminate\Console\Command->run() at vendor\symfony\console\Application.php:1040 Symfony\Component\Console\Application->doRunCommand() at vendor\symfony\console\Application.php:301 Symfony\Component\Console\Application->doRun() at vendor\symfony\console\Application.php:171 Symfony\Component\Console\Application->run() at vendor\laravel\framework\src\Illuminate\Console\Application.php:94 Illuminate\Console\Application->run() at vendor\laravel\framework\src\Illuminate\Foundation\Console\Kernel.php:129 Illuminate\Foundation\Console\Kernel->handle() at artisan:37

Please or to participate in this conversation.