douzhongpi9734 2015-12-21 15:05
浏览 75

Laravel - 仅在Safari和其他一些浏览器上使用HTTPS和AJAX时出错

When I'm doing a post request using AJAX, I'm getting this error:

PHP Parse error: syntax error, unexpected '/*' (T_STRING), expecting ')' in /home/laravel/public_html/public/index.php on line 47

PHP Fatal error: require(): Failed opening required '/home/user/public_html/vendor/ClassLoader.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/user/public_html/vendor/autoload.php on line 6

The index.php it's referring to is as following:

<?php

require __DIR__.'/../../laravel/bootstrap/autoload.php';
$app = require_once __DIR__.'/../../laravel/bootstrap/app.php';
$kernel = $app->make(Illuminate\Contracts\Http\Kernel::class);

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

$response->send();

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

I have no idea why this is happening.

This only happens in safari and a few other browsers. Doesn't happen on chrome.

The inspect element looks like this: Error on Web Developer Tools

Please help guys. Thanks

Edit: Folder structure:

home/user/laravel -> All my laravel files
home/user/laravel/public_html/public -> my public folder

When I do composer install, it gives me this error:

Warning: Composer should be invoked via the CLI version of PHP, not the cgi-fcgi SAPI
Composer could not find a composer.json file in /usr/bin

For some reason, it's looking for composer.json file in /usr/bin. The composer.json file is in the current directory in which I am cd'd to.

  • 写回答

2条回答 默认 最新

  • dongnaoben4456 2015-12-21 15:09
    关注

    Edit: index.php should look like this:

    <?php
    
    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()
    );
    
    $response->send();
    
    $kernel->terminate($request, $response);
    

    That will hopefully do the trick.

    The first line of any PHP file should be

    <?php
    

    Somehow that's missing in your copy of the index file. I'm not sure how that happened, but that would be the error you're seeing.

    评论

报告相同问题?

悬赏问题

  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 unity第一人称射击小游戏,有demo,在原脚本的基础上进行修改以达到要求
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)