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:
I copied the contents of public folder to the root folder of my project.
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
...
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]