1

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] (Symfony\Component\Debug\Exception\FatalThrowableError(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

Kasra GH
  • 157
  • 2
  • 5
  • 22
  • Does this answer your question? [What is the purpose of the question marks before type declaration in PHP7 (?string or ?int)?](https://stackoverflow.com/questions/48450739/what-is-the-purpose-of-the-question-marks-before-type-declaration-in-php7-stri) – Syscall Dec 28 '22 at 17:30

2 Answers2

0

I think you can use this to solve your problem.

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

$app = require_once DIR.'../bootstrap/app.php';
  • I don't understand your modification. I have to change these two lines. Otherwise, the app cannot find autoload.php and app.php – Kasra GH May 28 '18 at 10:25
0

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 ?