Laravel error: Declaration of XXX Solution

Source: Internet
Author: User

On another machine pull up the latest code, into the background of the Web site, found that the page blank, using PHP artisan cache:clear, PHP artisan clear-compiled and so on to clear the cache and compile the file or not, open the PHP error log to view, found error:

Fatal error:declaration of Illuminate\\auth\\sessionguard::basic () must compatible \\auth\\supportsbasicauth::basic () in/usr/share/nginx/html/tanteng.me/vendor/laravel/framework/src/illuminate/ auth/sessionguard.php on line 17

Find a workable solution on the web to modify the Composer.json file:

Ps://oddyzfr8z.qnssl.com/wp-content/uploads/2016/09/laravel-composer-json-post-install.png "/>

Replace the clear-compiled with the following modifications:

Php

"Post-install-cmd": [
-"PHP artisan clear-compiled",
+ "illuminate\\foundation\\composerscripts::p ostinstall",
"PHP Artisan Optimize"
],
"Post-update-cmd": [
-"PHP artisan clear-compiled",
+ "illuminate\\foundation\\composerscripts::p ostupdate",
"PHP Artisan Optimize"
]

Once the sudo composer update is executed again, the sudo composer Dump-autoload is back to normal.

By the way, let's take a look at both methods, file path laravel/framework/src/illuminate/foundation/composerscripts.php:


Class Composerscripts
{
/**
* Handle the Post-Install Composer event.
*
* @param \composer\script\event $event
* @return void
*/
public static function Postinstall (Event $event)
{
Require_once $event->getcomposer ()->getconfig ()->get (' Vendor-dir '). ' /autoload.php ';

Static::clearcompiled ();
}

/**
* Handle the Post-update Composer event.
*
* @param \composer\script\event $event
* @return void
*/
public static function Postupdate (Event $event)
{
Require_once $event->getcomposer ()->getconfig ()->get (' Vendor-dir '). ' /autoload.php ';

Static::clearcompiled ();
}

/**
* Clear the cached laravel bootstrapping files.
*
* @return void
*/
protected static function clearcompiled ()
{
$laravel = new Application (GETCWD ());

if (file_exists ($compiledPath = $laravel->getcachedcompilepath ())) {
@unlink ($compiledPath);
}

if (file_exists ($servicesPath = $laravel->getcachedservicespath ())) {
@unlink ($servicesPath);
}
}
}

Both of these methods clear the Laravel compilation file, which can be used later to install and update dependent script commands in Composer.json.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.