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

报告相同问题?

悬赏问题

  • ¥20 机器学习能否像多层线性模型一样处理嵌套数据
  • ¥20 西门子S7-Graph,S7-300,梯形图
  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题
  • ¥15 matlab不知道怎么改,求解答!!
  • ¥15 永磁直线电机的电流环pi调不出来
  • ¥15 用stata实现聚类的代码
  • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效