简体   繁体   中英

Class not found [ Laravel 5.5, production project]

I'm working with Laravel 5.5. I uploaded my project to server. But I got error which my project works fine local server.

Class 'App\\Models\\Textbox\\TextBox' not found Symfony\\Component\\Debug\\Exception\\FatalThrowableError

I know, I just run composer dump-autoload and its works fine. But main problem is main hosting server is bluehost/cpanel. I can't run any command with shell, because it say your account not verified and I can't do this, because account not mine.

But I looked for alternative solutions and just upload these folders to server after run dump-autoload in local server.

\bootstrap
\vendor\composer

But it doesn't work. Finally I just upload all of vendor folder and don't get any result.

Do I have to run dump-autoload only server commandline / bash ?
Can I solve this without run any commandline query in server ?

PS I looked all of related questions and all of solution from google but I can't make it ready for work :(

This is my folder structure:

在此处输入图片说明 在此处输入图片说明

Mind case of your class name.

As you see you get error:

App\Models\Textbox\TextBox

but your class is:

App\Models\TextBox\TextBox

so as you see directory / namespace is with capital B.

This is important for composer autoloading to have exact same classname and directory with valid case (assuming you are using PSR-4 but this is default for Laravel).

On Windows file/directory case doesn't matter so you can write your namespace also TEXTBOX (for Windows TEXTBOX directory is the same as textbox ), but on Linux server there is no TEXTBOX directory, there is no Textbox directory - there is only TextBox directory so it won't be possible to autoload class and that's why you are getting the error on production and on localhost it's working fine.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM