Robert
Robert

Reputation: 21

500 Error on new Laravel installation copied from git repo

Posting a question and then answering it myself because I couldn't find the answer out there.

I restored a Laravel project from a git repo, ran all of the normal composer and artisan commands to setup the project, and I was getting a 500 Server Error with no explanation of why the page would not load. Eventually I found the error in the Apache logs:

AH01215: PHP Fatal error:  Cannot declare interface Psr\\Log\\LoggerInterface, because the name is already in u
se in /.../laravelproject/bootstrap/cache/compiled.php on line 14048

Laravel wasn't even loading, so laravel's own storage/logs/laravel.log file didn't contain any help.

Since I was on a shared hosting account, the apache log file wasn't in an obvious location...always figure out where that's being stored so you can check there when Laravel isn't giving hints.

From composer.json, Here are the laravel and package versions that are being used. The server is running PHP 7.4.

 "require": {
        "php": ">=5.6.4",
        "barryvdh/laravel-debugbar": "^2.4",
        "guzzlehttp/guzzle": "*",
        "laravel/framework": "5.3.*",
        "laravelcollective/html": "^5.3.0",
        "maatwebsite/excel": "~2.1.0"
    },

Upvotes: 1

Views: 349

Answers (1)

Robert
Robert

Reputation: 21

Other help files on the web suggest including these two destinations from the .gitignore:

# Laravel 4 specific
bootstrap/compiled.php
app/storage/

# Laravel 5 & Lumen specific
public/storage
public/hot
storage/*.key
.env.*.php
.env.php
.env
Homestead.yaml
Homestead.json
composer.lock

My problem, as pointed out in that Apache error above was with bootstrap/cache/compiled.php and I haven't seen many references to that. Deleting this file solved the problem, and I think including it in the .gitignore file is probably a good idea going forward.

New .gitignore:

# Laravel 4 specific
bootstrap/compiled.php
app/storage/

# Laravel 5 & Lumen specific
public/storage
public/hot
storage/*.key
.env.*.php
.env.php
.env
Homestead.yaml
Homestead.json
composer.lock
bootstrap/cache/compiled.php

This problem likely happened because it wasn't a fresh installation, it was a clone of an older project that I was restoring to a new folder and the compiled file came along for the ride.

Upvotes: 1

Related Questions