skip to Main Content

First I must say that this question has been asked thousands of time.
I created my Laravel 5.5 project using:

composer create-project --prefer-dist laravel/laravel blog "5.5.*"

I didn’t add anything to the project. The project runs locally without a problem.
The problem arrives when I want to host the project on a shared hosting website(I’m using infinityfree.net)

Minimum PHP version for Laravel 5.5: PHP >= 7.0.0

My shared hosting site php version: PHP Version 7.0.19

The only changes that I made are these:

  1. I copied the contents of public folder to the root folder of my project.

  2. Then I put the entire Laravel app in the htdocs folder of the shared hosting site.

so the structure looks like this :

--htdocs 
    app
    bootstrap
    ...
    index.php
    js
    css
    ...
    routes
    vendors
    ...
  1. I changed these two lines in index.php (The app worked locally without a problem):

    require DIR.’/../vendor/autoload.php’;

    — I changed it to –>

    require DIR.’/vendor/autoload.php’;

    $app = require_once DIR.’/../bootstrap/app.php’;

    — I changed it to –>

    $app = require_once DIR.’/bootstrap/app.php’;

I still get this common error:

laravel.ERROR: Parse error: syntax error, unexpected ‘?’, expecting variable (T_VARIABLE) {“exception”:”[object] (SymfonyComponentDebugExceptionFatalThrowableError(code: 0): Parse error: syntax error, unexpected ‘?’, expecting variable (T_VARIABLE) at /home/vol11_7/epizy.com/epiz_22148680/htdocs/vendor/symfony/http-kernel/Exception/HttpException.php:24)
[stacktrace]

Link to my laravel.log file

2

Answers


  1. I think you can use this to solve your problem.

    require DIR.'../vendor/autoload.php';
    
    $app = require_once DIR.'../bootstrap/app.php';
    
    Login or Signup to reply.
  2. Laravel 5 require higher php version, you need change the php version to 7.1 or 7.2 on your hosting

    What you use current php version ?

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search