Search code examples
phplaravelhomestead

Why Fatal error: Uncaught Error: Class 'Illuminate\Foundation\Application' not found


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?


Solution

  • 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!