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条)

报告相同问题?

悬赏问题

  • ¥15 metadata提取的PDF元数据,如何转换为一个Excel
  • ¥15 关于arduino编程toCharArray()函数的使用
  • ¥100 vc++混合CEF采用CLR方式编译报错
  • ¥15 coze 的插件输入飞书多维表格 app_token 后一直显示错误,如何解决?
  • ¥15 vite+vue3+plyr播放本地public文件夹下视频无法加载
  • ¥15 c#逐行读取txt文本,但是每一行里面数据之间空格数量不同
  • ¥50 如何openEuler 22.03上安装配置drbd
  • ¥20 ING91680C BLE5.3 芯片怎么实现串口收发数据
  • ¥15 无线连接树莓派,无法执行update,如何解决?(相关搜索:软件下载)
  • ¥15 Windows11, backspace, enter, space键失灵