dougua4836 2018-06-30 09:11
浏览 19
已采纳

Laravel 5.3接口在DriverException.php第33行找不到Throwable

Last day I uploaded my Laravel project to the server. Everything was working fine like on the local system. Since today morning, When the user submits one of the POST requests, it throws the above error and rests all requests are working fine.

I tried with

composer dump-autoload cleared route and cache

Here is the DriverException.php

    <?php
/*
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 * This software consists of voluntary contributions made by many individuals
 * and is licensed under the MIT license. For more information, see
 * <http://www.doctrine-project.org>.
 */

namespace Doctrine\DBAL\Driver;

/**
 * Contract for a driver exception.
 *
 * Driver exceptions provide the SQLSTATE of the driver
 * and the driver specific error code at the time the error occurred.
 *
 * @author Steve M端ller <st.mueller@dzh-online.de>
 * @link   www.doctrine-project.org
 * @since  2.5
 */
interface DriverException extends \Throwable
{
    /**
     * Returns the driver specific error code if available.
     *
     * Returns null if no driver specific error code is available
     * for the error raised by the driver.
     *
     * @return integer|string|null
     */
    public function getErrorCode();

    /**
     * Returns the driver error message.
     *
     * @return string
     */
    public function getMessage();

    /**
     * Returns the SQLSTATE the driver was in at the time the error occurred.
     *
     * Returns null if the driver does not provide a SQLSTATE for the error occurred.
     *
     * @return string|null
     */
    public function getSQLState();
}

But none helped me.

  • 写回答

2条回答 默认 最新

  • dongyi6543 2018-06-30 10:05
    关注

    I guess it is not the answer you were hoping for, but the problem is that you are using code that is written for PHP 7. The Throwable interface was first introduced in PHP 7 and code using it will therefore not work on an older PHP version.

    My best guess is that, especially because the exception you showed is from a vendor package, that your own code base is fine and only a dependency is causing a problem (because you recently updated your dependencies). To solve this issue, what you can do is emulate a lower PHP version for your project within the composer.json than what your development machine is running (you seem to run PHP 7 there). composer itself will, without such a setting, always attempt to update to the latest packages compatible with the machine being run on (and of course with regards to the versions defined in the composer.json).

    Incidentally, just yesterday I answered a question where the exact feature I'm going to suggest now caused troubles (Homestead: How to upgrade PHP version), but in your case it will help. So please go ahead and add the following configuration part to your composer.json (best with the exact PHP version your server is running):

    "config": {
        "platform": {
            "php": "5.6.0"
        }
    }
    

    If there is already a config block in the composer.json, simply add the platform.php parameter to it. After that, run composer update to (most likely) downgrade the problematic packages.

    In case this doesn't solve the issue, you might need to manually find the problematic packages and lower the versions of them so that they work with your production PHP version.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥65 LineageOs-21.0系统编译问题
  • ¥30 关于#c++#的问题,请各位专家解答!
  • ¥15 App的会员连续扣费
  • ¥15 不同数据类型的特征融合应该怎么做
  • ¥15 用proteus软件设计一个基于8086微处理器的简易温度计
  • ¥15 用联想小新14Pro
  • ¥15 multisim中关于74ls192n和DSWPK开关仿真图分析(减法计数器)
  • ¥15 w3wp,exe 中发生未处理的 Microsoft ,NETFramework 异常。
  • ¥20 C51单片机程序及仿真(加减器)
  • ¥15 AQWA | 水动力分析 二阶波浪力