pyp*_*ism 1 php laravel laravel-4
当我使用运行应用程序时,每个路由都工作正常php artisan serve,但是当我尝试在 nginx 上运行它时,所有路由都工作正常,除了/json.json。它显示以下错误。
Constant LARAVEL_START already defined
Run Code Online (Sandbox Code Playgroud)
这是routes.php
<?php
Route::get('/', function()
{
return View::make('hello');
});
Route::get('json.json', 'HomeController@temp');
Route::post('anotheroute', 'HomeController@p');
});
Run Code Online (Sandbox Code Playgroud)
和 HomeController.php
<?php
include 'index.php' ;
class HomeController extends BaseController {
public function showWelcome()
{
return View::make('hello');
}
public function temp()
{
header('Access-Control-Allow-Origin: *');
$x = select_artist_by_name();
return Response::json(array_keys($x));
}
Run Code Online (Sandbox Code Playgroud)
就我而言,我的 laravel 项目的外部文件上出现此错误。
所以我在包含文件之前检查了是否定义了常量:
if (!defined('LARAVEL_START')) {
require __DIR__.'/../bootstrap/autoload.php';
$app = require_once __DIR__.'/../bootstrap/app.php';
$kernel = $app->make(Illuminate\Contracts\Http\Kernel::class);
$response = $kernel->handle(
$request = Illuminate\Http\Request::capture()
);
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6846 次 |
| 最近记录: |