Laravel - 调用未定义的方法Illuminate \ Foundation \ Application :: run()

时间:2018-01-16 16:13:41

标签: php laravel .htaccess

再一次,

我在这个Laravel世界中仍然是新人,我已经克服了许多问题,但这个让我发疯。错误说明如下:

  

调用未定义的方法Illuminate \ Foundation \ Application :: run()

我不知道还有什么去看。我发现bindShared()share()函数存在类似问题,但run()没有。

我猜它是一个"核心"功能,因为它负责部署整个应用程序。

我检查了以下内容:

  • htaccess(为了找到项目文件夹而修改)
  • Apache配置
  • PHP扩展程序(我想所有这些都已启用,否则项目会给我"哎呀"错误或500错误
  • Laravel \ Collective for HTML表单(由于之前的核心软件包已被弃用,我使用了该表单)

这是我的htaccess

<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews -Indexes
    </IfModule>

    RewriteEngine On

    # Handle Authorization Header
    RewriteCond %{HTTP:Authorization} .
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

    # Redirect Trailing Slashes If Not A Folder...
    RewriteCond %{REQUEST_FILENAME} !-d
    #RewriteCond %{REQUEST_URI} (.+)/$
    #RewriteRule ^ %1 [L,R=301]

    RewriteCond %{REQUEST_URI} !^/itccomercioexterior-system
    RewriteRule ^(.*)$ /itccomercioexterior-system/$1 [L]

    # Handle Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L] 

</IfModule>

这是我的index.php

<?php

/**
 * Laravel - A PHP Framework For Web Artisans
 *
 * @package  Laravel
 * @author   Taylor Otwell <taylor@laravel.com>
 */

define('LARAVEL_START', microtime(true));

/*
|--------------------------------------------------------------------------
| Register The Auto Loader
|--------------------------------------------------------------------------
|
| Composer provides a convenient, automatically generated class loader for
| our application. We just need to utilize it! We'll simply require it
| into the script here so that we don't have to worry about manual
| loading any of our classes later on. It feels great to relax.
|
*/

require __DIR__.'/laravel/vendor/autoload.php';

/*
|--------------------------------------------------------------------------
| Turn On The Lights
|--------------------------------------------------------------------------
|
| We need to illuminate PHP development, so let us turn on the lights.
| This bootstraps the framework and gets it ready for use, then it
| will load up this application so that we can run it and send
| the responses back to the browser and delight our users.
|
*/

$app = require_once __DIR__.'/laravel/bootstrap/app.php';

/*
|--------------------------------------------------------------------------
| Run The Application
|--------------------------------------------------------------------------
|
| Once we have the application, we can handle the incoming request
| through the kernel, and send the associated response back to
| the client's browser allowing them to enjoy the creative
| and wonderful application we have prepared for them.
|
*/

$kernel = $app->make(Illuminate\Contracts\Http\Kernel::class);

$response = $kernel->handle(
    $request = Illuminate\Http\Request::capture()
);

$response->send();

$kernel->terminate($request, $response);

try {
    $app->run();
} catch(\Exception $e) {
    echo "<pre>";
    echo $e;
    echo "</pre>";
}

最后我的树视图:

/project
├── css
│   ├── app.css
│   ├── bootstrap.css
│   ├── font-awesome.css
│   └── gridcss.css
├── favicon.ico
├── fonts
│   ├── fontawesome-webfont.eot
│   ├── fontawesome-webfont.svg
│   ├── fontawesome-webfont.ttf
│   ├── fontawesome-webfont.woff
│   └── fontawesome-webfont.woff2
├── index.php
├── js
│   ├── app.js
│   └── index.js
├── laravel
│   ├── app
│   ├── artisan
│   ├── bootstrap
│   ├── composer
│   ├── composer.json
│   ├── composer.lock
│   ├── config
│   ├── database
│   ├── package.json
│   ├── package-lock.json
│   ├── phpunit.xml
│   ├── readme.md
│   ├── resources
│   ├── routes
│   ├── server.php
│   ├── storage
│   ├── tests
│   ├── vendor
│   └── webpack.mix.js
├── media
│   ├── aduanas.jpg
│   ├── aduanas.png
│   ├── carousel001.jpg
│   ├── carousel002.jpg
│   ├── carousel003.png
│   ├── carousel004.jpg
│   ├── contacto.jpg
│   ├── curso1.jpg
│   ├── curso2.jpg
│   ├── curso3.jpg
│   ├── cursos.jpg
│   └── logo.webp
├── mix-manifest.json
├── robots.txt
├── storage
│   └── logs
└── web.config

任何见解都将受到赞赏!

再次感谢大家!

1 个答案:

答案 0 :(得分:1)

错误很明显:it doesn't exists a run method in the in the Illuminate\Foundation\Application class

这是从哪里来的?它看起来不像Laravel附带的index.php

try {
    $app->run();
} catch(\Exception $e) {
    echo "<pre>";
    echo $e;
    echo "</pre>";
}

您是否尝试删除它?