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

raffelustig's avatar

Used shift from 5.3 to 5.4 php artisan won't work

After composer update at the end:

php artisan optimize In LaravelGettextServiceProvider.php line 51: Call to undefined method Illuminate\Foundation\Application::share()

What could be the problem?

0 likes
20 replies
raffelustig's avatar

Changed as below but same problem (Instead of share one shall use singleton instead)

50 // Main class register 51 // $this->app['laravel-gettext'] = $this->app->share(function ($app) use ($configuration) { CHANGED TO BELOW 52 53 $this->app->singleton('laravel-gettext',function ($app) use ($configuration) {

Can I give some other command then composer update go get the change to be active? The line 51 is a comment so?

jlrdw's avatar

Compare your version of laravel (not framework), with a downloaded version with a compare tool. On Windows I use Winmerge.

Fix any differences.

Delete vendor folder and rename composer.lock.

Then run composer install.

Somehow something was missed in the upgrade.

Edit: backup current first.

raffelustig's avatar

I don't understand, when I do laravel -V -- I get Laravel Installer 4.2.8 What's my version of laravel and what is a downloaded version? What is there to compare? I did not really understood the laravel versions except framework. I also uses Mac and have not found any good comparing software.

raffelustig's avatar

My problem is that the system is not written by me and it is rather extensive. Here you can see the system: https://test.webshooter.se (the system on line in 5.3 that we try to upgrade in local Docker environment) and if you like you can login to get an idea of it’s complexity. Use utvtest15@webshooter.se with password BraWebshooter

The system is for pistol competition administration and covers register users. login, create competitions, register results, writing out result lists and so on.

raffelustig's avatar

When logged in, click on Tävlingar and Visa. Shows a competition setup and where. In this case Lunds Skjutbana and Lund is a town in southern Sweden.

raffelustig's avatar

So one of my problems is to determine what packages needs to be upgraded and how.

raffelustig's avatar

My composer.json: ​ { "name": "laravel/laravel", "description": "The Laravel Framework.", "keywords": [ "framework", "laravel" ], "license": "MIT", "type": "project", "require": { "php": ">=5.6.4", "laravel/framework": "5.4.*", "tecnickcom/tcpdf": "^6.2", "stripe/stripe-php": "^4.3", "xinax/laravel-gettext": "^4.0", "jenssegers/optimus": "^0.2.2", "pda/pheanstalk": "^3.1", "hisorange/browser-detect": "^2.0", "doctrine/dbal": "^2.5", "laravel/passport": "^1.0", "barryvdh/laravel-cors": "^0.8.2", "sentry/sentry-laravel": "^0.5.0", "maatwebsite/excel": "^2.1", "predis/predis": "^1.1", "lcobucci/jwt": "3.3.3", "laravelcollective/html": "5.4.*", "laravel/tinker": "~1.0" }, "require-dev": { "fzaninotto/faker": "~1.4", "mockery/mockery": "0.9.*", "phpunit/phpunit": "~5.7", "laravel/browser-kit-testing": "^1.0" }, "autoload": { "classmap": [ "database" ], "psr-4": { "App\\": "app/" } }, "autoload-dev": { "classmap": [ "tests/TestCase.php", "tests/BrowserKitTestCase.php" ] }, "scripts": { "post-root-package-install": [ "php -r \"file_exists('.env') || copy('.env.example', '.env');\"" ], "post-create-project-cmd": [ "php artisan key:generate" ], "post-install-cmd": [ "Illuminate\\Foundation\\ComposerScripts::postInstall", "php artisan optimize" ], "post-update-cmd": [ "Illuminate\\Foundation\\ComposerScripts::postUpdate", "php artisan optimize" ] }, "config": { "preferred-install": "dist" } } ​

jlrdw's avatar

@raffelustig Yes, and that can take a little time, you need to go into various packages composer.json files and make sure dependencies are correct (version requirements). I do not know if shift was supposed to take care of it, but if not just check one by one.

For example take sentry, they have a chart right on github of the laravel version each supports. https://github.com/getsentry/sentry-laravel

However for packages with no chart, you have to look inside composer.json files.

You can run composer update, and fix any dependencies you missed.

1 like
raffelustig's avatar

Hi. I'm at this now: In Container.php line 1090: Illegal offset type in unset

This is the function: protected function dropStaleInstances($abstract) { unset($this->instances[$abstract], $this->aliases[$abstract]); }

Have no clue what to do. Composer update seems to work ok, this comes when it does: @php artisan optimize

raffelustig's avatar

Forgot to say that it's in vendor:

/Users/ralph/laravel/webshooter_web/vendor/laravel/framework/src/Illuminate/Container/Container.php

jlrdw's avatar

@raffelustig there were some container changes from 5.3 to 5.4 I believe, do some research on the laravel repo and see if any of your custom code needs modified.

Normally an upgrade goes easier, when there's custom code involved in can be a little more involved.

raffelustig's avatar
raffelustig
OP
Best Answer
Level 2

Put this problem in trash can. Now working in Laravel 8 for the system instead. Have come a long way to success.

Please or to participate in this conversation.