Laravel - Class/Model not foundUsing models on packagesLaravel 4 - class not found on live serverLaravel 'Class not found'Autoload Helper folder Laravel 5Laravel 5 and Laravel 5.1 “Class 'Model Name' not found”, is there better solution?laravel - class not found for new service providerLaravel 5.1 Namespace for Controller give Reflection ExceptionLaravel5.2: controller class not found when i try to handle dataClass not found error laravel 5Laravel 5.2 custom helper not found
First-year PhD giving a talk among well-established researchers in the field
What do you call a weak person's act of taking on bigger opponents?
What reason would an alien civilization have for building a Dyson Sphere (or Swarm) if cheap Nuclear fusion is available?
Are there any vegetarian astronauts?
Why aren't (poly-)cotton tents more popular?
Require advice on power conservation for backpacking trip
Did Karl Marx ever use any example that involved cotton and dollars to illustrate the way capital and surplus value were generated?
Can ADFS connect to other SSO services?
What is the legal status of travelling with (unprescribed) methadone in your carry-on?
Is this one of the engines from the 9/11 aircraft?
What kind of wire should I use to pigtail an outlet?
Character discovers anti gravity emitters, flies a shipping container into space and docks with space station
Plotting with different color for a single curve
Why do textbooks often include the solutions to odd or even numbered problems but not both?
How well known and how commonly used was Huffman coding in 1979?
Is there any evidence that the small canisters (10 liters) of 95% oxygen actually help with altitude sickness?
Why is the Turkish president's surname spelt in Russian as Эрдоган, with г?
Smooth Julia set for quadratic polynomials
Should I tell my insurance company I'm making payments on my new car?
Fetch and print all properties of an object graph as string
Animation advice please
Does ultrasonic bath cleaning damage laboratory volumetric glassware calibration?
Through the Looking-Glass
Impossible darts scores
Laravel - Class/Model not found
Using models on packagesLaravel 4 - class not found on live serverLaravel 'Class not found'Autoload Helper folder Laravel 5Laravel 5 and Laravel 5.1 “Class 'Model Name' not found”, is there better solution?laravel - class not found for new service providerLaravel 5.1 Namespace for Controller give Reflection ExceptionLaravel5.2: controller class not found when i try to handle dataClass not found error laravel 5Laravel 5.2 custom helper not found
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
Initially, this code worked, but it doesn't work anymore. I don't know what is causing the issue.
The error is :
FatalErrorException in AdminController.php line 64:
Class 'AppCategory' not found
AdminController
code is:
<?php
namespace AppHttpControllers;
use Request;
use AppHttpRequests;
use AppHttpControllersController;
use AppCategory;
use View;
class AdminController extends Controller
public function article_get()
$categories = Category::latest()->get();
return View::make('create.article')->with('categories',$categories);
My model Category is located at App/Models/Category.php
.
What I've tried:
- Change from
use AppCategory;
touse Category
, touse Category
, touse AppModelsCategory
. composer dump-autoload
.
A few hours ago I had a working project, but now my models are not found.
php laravel models
add a comment |
Initially, this code worked, but it doesn't work anymore. I don't know what is causing the issue.
The error is :
FatalErrorException in AdminController.php line 64:
Class 'AppCategory' not found
AdminController
code is:
<?php
namespace AppHttpControllers;
use Request;
use AppHttpRequests;
use AppHttpControllersController;
use AppCategory;
use View;
class AdminController extends Controller
public function article_get()
$categories = Category::latest()->get();
return View::make('create.article')->with('categories',$categories);
My model Category is located at App/Models/Category.php
.
What I've tried:
- Change from
use AppCategory;
touse Category
, touse Category
, touse AppModelsCategory
. composer dump-autoload
.
A few hours ago I had a working project, but now my models are not found.
php laravel models
What is your namespace inCategory.php
?
– BrokenBinary
Sep 24 '15 at 22:45
@brokenbinary, namespace App. Also, if I create a model at 'App/Category.php', it will be fine and working.
– Rei Daigo
Sep 25 '15 at 6:51
add a comment |
Initially, this code worked, but it doesn't work anymore. I don't know what is causing the issue.
The error is :
FatalErrorException in AdminController.php line 64:
Class 'AppCategory' not found
AdminController
code is:
<?php
namespace AppHttpControllers;
use Request;
use AppHttpRequests;
use AppHttpControllersController;
use AppCategory;
use View;
class AdminController extends Controller
public function article_get()
$categories = Category::latest()->get();
return View::make('create.article')->with('categories',$categories);
My model Category is located at App/Models/Category.php
.
What I've tried:
- Change from
use AppCategory;
touse Category
, touse Category
, touse AppModelsCategory
. composer dump-autoload
.
A few hours ago I had a working project, but now my models are not found.
php laravel models
Initially, this code worked, but it doesn't work anymore. I don't know what is causing the issue.
The error is :
FatalErrorException in AdminController.php line 64:
Class 'AppCategory' not found
AdminController
code is:
<?php
namespace AppHttpControllers;
use Request;
use AppHttpRequests;
use AppHttpControllersController;
use AppCategory;
use View;
class AdminController extends Controller
public function article_get()
$categories = Category::latest()->get();
return View::make('create.article')->with('categories',$categories);
My model Category is located at App/Models/Category.php
.
What I've tried:
- Change from
use AppCategory;
touse Category
, touse Category
, touse AppModelsCategory
. composer dump-autoload
.
A few hours ago I had a working project, but now my models are not found.
php laravel models
php laravel models
edited Sep 25 '15 at 15:49
dayuloli
7,54211 gold badges49 silver badges97 bronze badges
7,54211 gold badges49 silver badges97 bronze badges
asked Sep 24 '15 at 22:32
Rei DaigoRei Daigo
11 silver badge1 bronze badge
11 silver badge1 bronze badge
What is your namespace inCategory.php
?
– BrokenBinary
Sep 24 '15 at 22:45
@brokenbinary, namespace App. Also, if I create a model at 'App/Category.php', it will be fine and working.
– Rei Daigo
Sep 25 '15 at 6:51
add a comment |
What is your namespace inCategory.php
?
– BrokenBinary
Sep 24 '15 at 22:45
@brokenbinary, namespace App. Also, if I create a model at 'App/Category.php', it will be fine and working.
– Rei Daigo
Sep 25 '15 at 6:51
What is your namespace in
Category.php
?– BrokenBinary
Sep 24 '15 at 22:45
What is your namespace in
Category.php
?– BrokenBinary
Sep 24 '15 at 22:45
@brokenbinary, namespace App. Also, if I create a model at 'App/Category.php', it will be fine and working.
– Rei Daigo
Sep 25 '15 at 6:51
@brokenbinary, namespace App. Also, if I create a model at 'App/Category.php', it will be fine and working.
– Rei Daigo
Sep 25 '15 at 6:51
add a comment |
4 Answers
4
active
oldest
votes
Because Laravel uses PSR-4 autoloading, you need to make sure your namespaces match the real directory structure.
You say that your Category
model is located at App/Models/Category.php
so its namespace should be AppModels
. Then, in your controllers you would use AppModelsCategory
.
add a comment |
Your code seems fine.
May be it has an issue with namespace in Category model.
if you use this code for Category Model in your AdminController controller:
use AppModelsCategory;
then your Category model itself has this namespace
namespace AppModels;
Check if your model namespace is still there or not.
Thanks
add a comment |
Do it like this and it must work:
use AppModelsCategory
and make sure that the model Category is inside a folder named Models.
add a comment |
I had also faced the same error when Models are called inside Controllers or Seeders.
The best solution is to import your Model inside the Controllers.
Add the below line at the top of your AdminController.
use AppModelsCategory
This is applicable for all Classes where you try to call your models.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f32772019%2flaravel-class-model-not-found%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
4 Answers
4
active
oldest
votes
4 Answers
4
active
oldest
votes
active
oldest
votes
active
oldest
votes
Because Laravel uses PSR-4 autoloading, you need to make sure your namespaces match the real directory structure.
You say that your Category
model is located at App/Models/Category.php
so its namespace should be AppModels
. Then, in your controllers you would use AppModelsCategory
.
add a comment |
Because Laravel uses PSR-4 autoloading, you need to make sure your namespaces match the real directory structure.
You say that your Category
model is located at App/Models/Category.php
so its namespace should be AppModels
. Then, in your controllers you would use AppModelsCategory
.
add a comment |
Because Laravel uses PSR-4 autoloading, you need to make sure your namespaces match the real directory structure.
You say that your Category
model is located at App/Models/Category.php
so its namespace should be AppModels
. Then, in your controllers you would use AppModelsCategory
.
Because Laravel uses PSR-4 autoloading, you need to make sure your namespaces match the real directory structure.
You say that your Category
model is located at App/Models/Category.php
so its namespace should be AppModels
. Then, in your controllers you would use AppModelsCategory
.
edited Sep 25 '15 at 15:40
answered Sep 25 '15 at 15:34
BrokenBinaryBrokenBinary
5,3192 gold badges32 silver badges46 bronze badges
5,3192 gold badges32 silver badges46 bronze badges
add a comment |
add a comment |
Your code seems fine.
May be it has an issue with namespace in Category model.
if you use this code for Category Model in your AdminController controller:
use AppModelsCategory;
then your Category model itself has this namespace
namespace AppModels;
Check if your model namespace is still there or not.
Thanks
add a comment |
Your code seems fine.
May be it has an issue with namespace in Category model.
if you use this code for Category Model in your AdminController controller:
use AppModelsCategory;
then your Category model itself has this namespace
namespace AppModels;
Check if your model namespace is still there or not.
Thanks
add a comment |
Your code seems fine.
May be it has an issue with namespace in Category model.
if you use this code for Category Model in your AdminController controller:
use AppModelsCategory;
then your Category model itself has this namespace
namespace AppModels;
Check if your model namespace is still there or not.
Thanks
Your code seems fine.
May be it has an issue with namespace in Category model.
if you use this code for Category Model in your AdminController controller:
use AppModelsCategory;
then your Category model itself has this namespace
namespace AppModels;
Check if your model namespace is still there or not.
Thanks
answered Sep 25 '15 at 10:28
Md Rashedul Hoque BhuiyanMd Rashedul Hoque Bhuiyan
3,7062 gold badges21 silver badges34 bronze badges
3,7062 gold badges21 silver badges34 bronze badges
add a comment |
add a comment |
Do it like this and it must work:
use AppModelsCategory
and make sure that the model Category is inside a folder named Models.
add a comment |
Do it like this and it must work:
use AppModelsCategory
and make sure that the model Category is inside a folder named Models.
add a comment |
Do it like this and it must work:
use AppModelsCategory
and make sure that the model Category is inside a folder named Models.
Do it like this and it must work:
use AppModelsCategory
and make sure that the model Category is inside a folder named Models.
answered Sep 25 '15 at 10:08
patriciopatricio
1651 gold badge3 silver badges13 bronze badges
1651 gold badge3 silver badges13 bronze badges
add a comment |
add a comment |
I had also faced the same error when Models are called inside Controllers or Seeders.
The best solution is to import your Model inside the Controllers.
Add the below line at the top of your AdminController.
use AppModelsCategory
This is applicable for all Classes where you try to call your models.
add a comment |
I had also faced the same error when Models are called inside Controllers or Seeders.
The best solution is to import your Model inside the Controllers.
Add the below line at the top of your AdminController.
use AppModelsCategory
This is applicable for all Classes where you try to call your models.
add a comment |
I had also faced the same error when Models are called inside Controllers or Seeders.
The best solution is to import your Model inside the Controllers.
Add the below line at the top of your AdminController.
use AppModelsCategory
This is applicable for all Classes where you try to call your models.
I had also faced the same error when Models are called inside Controllers or Seeders.
The best solution is to import your Model inside the Controllers.
Add the below line at the top of your AdminController.
use AppModelsCategory
This is applicable for all Classes where you try to call your models.
answered Oct 13 '17 at 17:48
MichelMichel
5594 silver badges19 bronze badges
5594 silver badges19 bronze badges
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f32772019%2flaravel-class-model-not-found%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
What is your namespace in
Category.php
?– BrokenBinary
Sep 24 '15 at 22:45
@brokenbinary, namespace App. Also, if I create a model at 'App/Category.php', it will be fine and working.
– Rei Daigo
Sep 25 '15 at 6:51