1

I have a Laravel/Homestead project that is finally working locally. Now I'm trying to port it over to HostGator and can't get it running due to titled error. I've tried all the suggested solutions to no avail. Including:

composer require laravel/laravel
composer dump-autoload
composer install --no-scripts
composer update
composer update --no-scripts

Nothing works. Same error. If this is a clue, I also tried

php artisan clear-compiled

and get response of

Could not open input file: artisan

I'm about ready to give up on Laravel/Homestead. I've spent countless hours on this framework with nothing but problems to show for it. Would not recommend it to anybody.

You can see the error yourself here: http://www.tekknow.net/MedAverter/medaverter/

Any suggestions before I throw in the towel?

user3217883
  • 1,216
  • 4
  • 38
  • 65
  • Does this answer your question? [Fatal error: Class 'Illuminate\Foundation\Application' not found](https://stackoverflow.com/questions/29764368/fatal-error-class-illuminate-foundation-application-not-found) – Sehdev Mar 23 '20 at 04:04

2 Answers2

0

For the artisan file, the artisan file is not required through includes, you have it in your root project, which is created when you create your Laravel project. Here is the file.

So you need to have that file in your project.

For the missing class, you try to require laravel/laravel but that is not the correct dependency. Again that github repo is a shell for a project, to have Laravel features you need to base of laravel/laravel and include laravel/framework.

Hope this clears up some confusing and can get you on the right track. Secondly you shouldn't port it over, but simply cloning your project and running composer install should be sufficient.

mrhn
  • 17,961
  • 4
  • 27
  • 46
  • What is the name of the artisan file you pointed me to and where do I put it exactly? Which file should have the include laravel/framwork? What does it mean to "base of laravel/laravel? By port, I meant clone. I cloned the code I pushed to BitBucket. Can you point me to a simple tutorial that explains how to get a project that works locally, running on a shared host server? – user3217883 Mar 23 '20 at 13:56
  • Do you have an file called artisan in your project? – mrhn Mar 23 '20 at 14:58
  • I don't believe I have run that one. I just tried it now from the same medaverter folder. Here is the response: "-jailshell: artisan: command not found" – user3217883 Mar 24 '20 at 00:59
  • Silly me, I forgot the "php" in front of artisan. Here is the correct one: user@tekknow.net [~/www/MedAverter/medaverter]# php artisan clear-compiled Warning: require(/home1/sl1k7f3j/public_html/MedAverter/medaverter/vendor/autoload.php): failed to open stream: No such file or directory in /home1/sl1k7f3j/public_html/MedAverter/medaverter/artisan on line 18 Fatal error: require(): Failed opening required '/home1/sl1k7f3j/public_html/MedAverter/medaverter/vendor/autoload.php' (include_path='.:/opt/php56/lib/php') in /home1/user/public_html/MedAverter/medaverter/artisan on line 18 – user3217883 Mar 24 '20 at 01:09
  • I'm starting to think all these problems are because I created a folder MedAverter and cloned the code into there. Maybe I should have put it directly into ~/www. Anyway, I moved the vendor and bootstrap folders into the medaverter folder and ran php artisan clear-compiled again. Here is the output: "Parse error: syntax error, unexpected '?' in /home1/sl1k7f3j/public_html/MedAverter/medaverter/bootstrap/app.php on line 15" Here is lines 14 and 15 in that file: $app = new Illuminate\Foundation\Application( $_ENV['APP_BASE_PATH'] ?? dirname(__DIR__) – user3217883 Mar 24 '20 at 01:18
  • That seems like you are running the wrong version of php compared to the syntax you are using. – mrhn Mar 24 '20 at 02:08
  • I've set the php version to 7.1 in HostGator cPanel – user3217883 Mar 24 '20 at 02:26
  • I deleted everything and started over, cloning directly into ~/www. Same error! – user3217883 Mar 24 '20 at 02:27
  • since it clearly can't parse the null coalescent operator, it seems like you are in the wrong php version. php -v can claim that. – mrhn Mar 24 '20 at 02:33
  • Yea, you might be onto something there. php -v shows PHP 5.6.30 (cli) (built: Mar 27 2017 11:48:20) even though cPanel shows 7.1. I'll call HostGator to see what gives. I also followed this tutorial: https://www.5balloons.info/hosting-laravel-5-5-project-on-shared-hosting-hostgator/ When I get to the php artisan key:generate, output is "Parse error: syntax error, unexpected '?' in /home1/sl1k7f3j/public_html/medaverter/bootstrap/app.php on line 15", same thing I was getting before. – user3217883 Mar 24 '20 at 03:22
0

The problem turned out to be two issues. 1. The wrong version of PHP was running. If I ssh'ed into the hostgator server and did

php -v

It showed PHP 5.6.30 even though I had selected Php 7.1 in the cPanel PHP Selector. If I did

tekknow.net/phpinfo.php

it would say I was using 7.1. Called up HostGator tech support and they were able to change it to PHP 7.3.13.

Now if I do:

php artisan clear cache

I no longer get the error about

Parse error: syntax error, unexpected '?' in /home1/sl1k7f3j/public_html/medaverter/bootstrap/app.php on line 15

which was an error caused by a version of php that doesn't support the ?? operator.

  1. The second problem was a lack of memory issue. If I did

    composer update It would start to work but would fail in about 30 seconds with

Fatal error: Out of memory (allocated 709623808) (tried to allocate 34187559 bytes) in phar:///opt/cpanel/composer/bin/composer/src/Composer/Json/JsonFile.php on line 270

The HostGator tech rep could not figure out why that was happening but I got around that issue by manually uploading my local vendor folder to the host server.

Now when I go to http://tekknow.net/medaverter/ it works!

user3217883
  • 1,216
  • 4
  • 38
  • 65