11

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 /home/abdullah/php_apps/website/vendor/laravel/tinker/src/ClassAliasAutoloader.php:51
Stack trace:
#0 /home/abdullah/php_apps/website/vendor/laravel/tinker/src/ClassAliasAutoloader.php(51): Illuminate\Foundation\Bootstrap\HandleExceptions->handleError(2, 'require(/home/a...', '/home/abdullah/...', 51, Array)
#1 /home/abdullah/php_apps/website/vendor/laravel/tinker/src/ClassAliasAutoloader.php(51): require()
#2 /home/abdullah/php_apps/website/vendor/laravel/tinker/src/ClassAliasAutoloader.php(33): Laravel\Tinker\ClassAliasAutoloader->__construct(Object(Psy\Shell), '/home/abdullah/...')
#3 /home/abdullah/php_apps/website/vendor/laravel/tinker/src/Console/TinkerCommand.php(59): Laravel\Tinker\ClassAliasAutoloader::register(Object(Psy\Shell), '/home/abdullah/...')
#4 [internal function]: Laravel\Tinker\Console\TinkerCommand->handle()
#5 /home/abdullah/php_apps/website/vendor/laravel/framework/src/Illuminate/Contai in /home/abdullah/php_apps/website/vendor/laravel/tinker/src/ClassAliasAutoloader.php on line 51
PHP Fatal error:  Laravel\Tinker\ClassAliasAutoloader::__construct(): Failed opening required '/home/abdullah/php_apps/website' (include_path='.:/home/abdullah/.phpbrew/php/php-7.0.1/lib/php') in /home/abdullah/php_apps/website/vendor/laravel/tinker/src/ClassAliasAutoloader.php on line 51


  [Symfony\Component\Debug\Exception\FatalErrorException]                                                                                                                         
  Laravel\Tinker\ClassAliasAutoloader::__construct(): Failed opening required '/home/abdullah/php_apps/website' (include_path='.:/home/abdullah/.phpbrew/php/php-7.0.1/lib/php')  

I have tried giving rights to various folders. Also tried adding the Tinker class to console/kernel.php.

krlzlx
  • 5,752
  • 14
  • 47
  • 55
AMBasra
  • 969
  • 8
  • 24
  • Does `Laravel\Tinker\TinkerServiceProvider::class,` exist in your config/app.php file? Also, try running `composer dump-autoload` and trying again – Chris Forrence Aug 16 '17 at 15:11
  • @ChrisForrence Yes it exists and I have tried composer dump-autoload multiple times – AMBasra Aug 16 '17 at 15:30
  • Maybe there is an unresolved `Success` class/facade as of this error `failed to open stream: Success`; the actual application runs with no errors at all? Did that happen suddenly after some additions or it's a fresh installation? – Christos Lytras Aug 18 '17 at 17:56
  • @ChristosLytras Thank you for your comment. Yes the actual app runs smoothly. php artisan serve works perfectly. This app is in laravel 5.4 and didnt have the tinker package in the composer.json. I added that and also added the entry in list of providers but couldnt get that to work. – AMBasra Aug 18 '17 at 19:10
  • I think you have to add it inside `app/Console/Kernel.php` in the `commands` array like this `protected $commands = [ \Laravel\Tinker\Console\TinkerCommand::class ];` in order to work. Please try that and update. – Christos Lytras Aug 18 '17 at 21:47
  • @ChristosLytras Thankyou again for your message. I have already tried that but confirmed again after your message. Still no avail. I will try this with new laravel empty project. Might give some new insight. – AMBasra Aug 18 '17 at 22:01
  • @ChristosLytras It works with new app. – AMBasra Aug 18 '17 at 22:27
  • @AMBasra that's a clue that there is something wrong inside your current app code that breaks tinker from starting. That's why I suggested to search for something related to this line `failed to open stream: Success`. – Christos Lytras Aug 18 '17 at 22:30
  • At `laravel/tinker/src/ClassAliasAutoloader.php:51` there is a require class mapper `$classes = require $classMapPath;` that tries to load something from `/home/abdullah/php_apps/website`. Can you update and provide the `config/app.php` file contents? – Christos Lytras Aug 18 '17 at 22:41
  • @ChristosLytras Well i fixed it finally. The issue was laravel v5.4.0 vs laravel v5.4.33. I updated my laravel to 5.4.33 and all is fine. Oh my that was something. – AMBasra Aug 18 '17 at 22:48
  • @AMBasra nice you got that fixed. It can be really tricky with these version issues. – Christos Lytras Aug 18 '17 at 22:50
  • @ChristosLytrasThankyou so much for your help. Highly appreciated. – AMBasra Aug 20 '17 at 16:34

1 Answers1

7

I fixed it finally by upgrading my version of laravel. Laravel v5.4.0 to Laravel v5.4.33.

AMBasra
  • 969
  • 8
  • 24