5

I am upgrading from Laravel 5.3 to Laravel 5.4. Problem is that when I run composer update and when it comes to php artisan optimize part, I get an error:

[Symfony\Component\Debug\Exception\FatalErrorException]
  Call to undefined method Illuminate\Foundation\Application::share()

I've read a couple of questions here on StackOverflow and the answer is to replace this share method with singleton. But where can I find this share()?

EDIT

My composer.json file:

    "name": "laravel/laravel",
    "description": "The Laravel Framework.",
    "keywords": ["framework", "laravel"],
    "license": "MIT",
    "type": "project",
    "require": {
        "php": ">=5.6.4",
        "laravel/framework": "5.4.*",
        "sngrl/sphinxsearch": "dev-master",
        "laravelcollective/html": "5.4.*",
        "aws/aws-sdk-php-laravel": "~3.0",
        "league/flysystem-aws-s3-v3": "^1.0",
        "mcamara/laravel-localization": "1.2.*",
        "league/csv": "^8.2",
        "mikehaertl/phpwkhtmltopdf": "^2.2",
        "barryvdh/laravel-snappy": "^0.3.3",
        "wemersonjanuario/wkhtmltopdf-windows": "dev-master",
        "nesbot/carbon": "^1.22",
        "uxweb/sweet-alert": "^1.4",
        "laracasts/flash": "^2.0",
        "guzzlehttp/guzzle": "^6.2",
        "illuminate/support": "5.4.*",
        "laravel/scout": "^3.0"
    },
    "require-dev": {
        "fzaninotto/faker": "~1.4",
        "mockery/mockery": "0.9.*",
        "phpunit/phpunit": "~5.7",
        "symfony/css-selector": "3.1.*",
        "symfony/dom-crawler": "3.1.*"
    },
    "autoload": {
        "classmap": [
            "database"
        ],
        "psr-4": {
            "App\\": "app/"
        }
    },
    "autoload-dev": {
        "classmap": [
            "tests/TestCase.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"
    }
}
harunB10
  • 4,823
  • 15
  • 63
  • 107

1 Answers1

-1

Project Share() method file is the Following Path:

Your Project >> Vendor >> laravel >> framework >> src >> Illuminate >> Container >> Container.php

Comment your share() method code and put below code.

public function singleton($abstract, $concrete = null)
{
   $this->bind($abstract, $concrete, true);
}
halfer
  • 19,824
  • 17
  • 99
  • 186
AddWeb Solution Pvt Ltd
  • 21,025
  • 5
  • 26
  • 57
  • It is already done. I have a singleton instead of share function. Problem is somewhere else. – harunB10 Aug 31 '17 at 12:05
  • @harunB10, Plase share your composer.json file. OR Try with comment all your Third Party ServiceProviders & UnComment one by one (i.e. config/app.php) – AddWeb Solution Pvt Ltd Aug 31 '17 at 14:20
  • I have same issue, commented share() and added singleton, but still I am getting same error, Its not resolving my issue – Ali Jul 16 '23 at 05:24
  • Modifying core code in laravel is ALWAYS an awful idea. It means you break your update path. The answer should contain the issue and a solution that extends or overrides but leaves core code alone. – Bill Garrison Jul 19 '23 at 17:50