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;








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:



  1. Change from use AppCategory; to use Category, to use Category, to use AppModelsCategory.


  2. composer dump-autoload.

A few hours ago I had a working project, but now my models are not found.










share|improve this question
























  • 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


















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:



  1. Change from use AppCategory; to use Category, to use Category, to use AppModelsCategory.


  2. composer dump-autoload.

A few hours ago I had a working project, but now my models are not found.










share|improve this question
























  • 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














0












0








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:



  1. Change from use AppCategory; to use Category, to use Category, to use AppModelsCategory.


  2. composer dump-autoload.

A few hours ago I had a working project, but now my models are not found.










share|improve this question
















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:



  1. Change from use AppCategory; to use Category, to use Category, to use AppModelsCategory.


  2. composer dump-autoload.

A few hours ago I had a working project, but now my models are not found.







php laravel models






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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


















  • 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

















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













4 Answers
4






active

oldest

votes


















2














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.






share|improve this answer
































    1














    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






    share|improve this answer






























      0














      Do it like this and it must work:



      use AppModelsCategory


      and make sure that the model Category is inside a folder named Models.






      share|improve this answer






























        0














        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.






        share|improve this answer

























          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
          );



          );













          draft saved

          draft discarded


















          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









          2














          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.






          share|improve this answer





























            2














            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.






            share|improve this answer



























              2












              2








              2







              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.






              share|improve this answer















              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.







              share|improve this answer














              share|improve this answer



              share|improve this answer








              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























                  1














                  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






                  share|improve this answer



























                    1














                    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






                    share|improve this answer

























                      1












                      1








                      1







                      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






                      share|improve this answer













                      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







                      share|improve this answer












                      share|improve this answer



                      share|improve this answer










                      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





















                          0














                          Do it like this and it must work:



                          use AppModelsCategory


                          and make sure that the model Category is inside a folder named Models.






                          share|improve this answer



























                            0














                            Do it like this and it must work:



                            use AppModelsCategory


                            and make sure that the model Category is inside a folder named Models.






                            share|improve this answer

























                              0












                              0








                              0







                              Do it like this and it must work:



                              use AppModelsCategory


                              and make sure that the model Category is inside a folder named Models.






                              share|improve this answer













                              Do it like this and it must work:



                              use AppModelsCategory


                              and make sure that the model Category is inside a folder named Models.







                              share|improve this answer












                              share|improve this answer



                              share|improve this answer










                              answered Sep 25 '15 at 10:08









                              patriciopatricio

                              1651 gold badge3 silver badges13 bronze badges




                              1651 gold badge3 silver badges13 bronze badges





















                                  0














                                  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.






                                  share|improve this answer



























                                    0














                                    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.






                                    share|improve this answer

























                                      0












                                      0








                                      0







                                      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.






                                      share|improve this answer













                                      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.







                                      share|improve this answer












                                      share|improve this answer



                                      share|improve this answer










                                      answered Oct 13 '17 at 17:48









                                      MichelMichel

                                      5594 silver badges19 bronze badges




                                      5594 silver badges19 bronze badges



























                                          draft saved

                                          draft discarded
















































                                          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.




                                          draft saved


                                          draft discarded














                                          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





















































                                          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







                                          Popular posts from this blog

                                          Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

                                          SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

                                          은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현