Class not loading on Hosting but works on localhost - Laravel 5

Christophvh

I have a Laravel 5 project running perfectly on localhost. I uploaded the project to a webhost and suddenly i get an error on a simple class.

This is the error:

FatalThrowableError in HomeController.php line 20:
Fatal error: Class 'App\Blogpost' not found

The Homecontroller code is this:

<?php

namespace App\Http\Controllers;

use App\Http\Requests;
use App\Blogpost;
use Illuminate\Http\Request;

class HomeController extends Controller
{

    /**
     * Show the application dashboard.
     *
     * @return \Illuminate\Http\Response
     */
    public function index()
    {

        $blogposts = Blogpost::latest()->take(6)->get();

        return view('pages/start', compact('blogposts'));
    }
}

This code is pretty basic and works fine on localhost so i assume that the problem is located elsewhere, but i'm not sure where to begin searching?

For testing purposes i put all the code from Homecontroller in comments and than i just get an error on something else so the problem is situated elsewhere.

My localhost runs on MAMP with a Apache Server with PHP 7.0.0 . Hosting runs on Linux + Apache + PHP 7.0.5 .

I have uploaded other laravel projects to the same server with the same configuration without any problems.

this is the link if that helps: [http://dev.mayan-co.com][1]

Extra code to show the Blogpost class itself (still pretty sure the problem is not in that class)

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;
use Cviebrock\EloquentSluggable\SluggableInterface;
use Cviebrock\EloquentSluggable\SluggableTrait;

class BlogPost extends Model implements SluggableInterface
{
    protected $table = "blogposts";
    use SluggableTrait;

    protected $sluggable = [
        'build_from' => 'title',
        'save_to'    => 'slug',
    ];


    protected $fillable = [
        'title',
        'featured_image',
        'video_key',
        'body',
        'summary'
    ];

    public function tags()
    {
      return $this->belongsToMany('App\Tag', "blog_tag", "blogpost_id")->withTimestamps();
    }


    public function delete()
    {
      \File::delete([
        $this->featured_image,
      ]);

      parent::delete();
    }
}

Proof that Blogpost.php exists in the correct directory. enter image description here

Jeemusu

Your filename is BlogPost.php, yet your class is declared and instantiated as Blogpost. The filename and classname need to be identical in both name and case.

OSX is not case sensitive like most versions of linux hence why this is not happening to you on your local version.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

laravel + vue js API store function doesn't work on shared hosting but works well on localhost

Twitter APIs not working on hosting [Works fine on localhost]

Website works good in localhost but not in hosting server

laravel 5.3 hosting issue - not loading css

Laravel not loading assets on IIS 8 Shared Hosting

Shared hosting: WordPress/laravel 5

localhost is not loading project files in laravel

Loading dynamic webpage with Puppeteer works on localhost but not Heroku

Chartkick works on localhost but displays "loading" on heroku

Delete Ajax works in localhost - but doesn't in production hosting

The Advanced Custom Fields plugin works on Localhost but Hosting does not work

Issue with document.cookie: Works in localhost but Returns Empty on Web Hosting

Loading a composer class in laravel

Laravel cron job runs in localhost but not in my shared hosting with cpanel

Laravel: while hosting xampp on localhost in mac getting an error UnexpectedValueException

Laravel 5 – Clear Cache in Shared Hosting Server

How to Deploy Laravel 5 on shared cPanel hosting

Laravel-Mix + BrowserSync Not Loading at localhost:3000

Laravel passport returning Unauthenticated in production but works on localhost

Laravel Eager Loading not working, while lazy loading the same works

laravel 5 autoload not loading models

Boostrap modal not loading in Laravel 5

Laravel 5 eager loading with limit

Laravel 5 Eager loading with a function

Hosting a git server on localhost

Firebase hosting rewrites on localhost?

Laravel 5 Model class

Laravel 5 issues on shared hosting with pathinfo() and unwritable directory

how to run laravel 5 in shared hosting without composer?