samedi 23 juillet 2016

Laravel 5: organised models in subdirectory not found

I am trying to organise my app a bit better by putting models and controllers in subdirectories. I thought it didn't matter if they were in subdirectories as long as the namespace is correct, but now that I've moved them I'm getting a class not found error.

I have tried running composer dumpautoload several times, but it's still not working.

Here is my directory structure:

  • App
  • Models
    • Managers
      • EntryStructure.php
      • FieldManager.php
  • Controllers
    • EntryControllers.php

Since I have made the new directory Managers and moved those two models in there, When I reference the FieldManager class from EntryStructure, I get the not found error.

Code in EntryStructure.php:

namespace Pascall\ICMS\Models;

use Pascall\ICMS\Models\FieldManager;

class EntryStructure
    {
     function index(){
       new FieldManager(); // class not found
     }
    }

Code in FieldManager.php:

namespace Pascall\ICMS\Models;

class FieldManager {
  //      
}

Why is it not finding the FieldManager class when it is explicitly referenced in the use statement and they share the same namespace?



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2a1dczO
via IFTTT

Aucun commentaire:

Enregistrer un commentaire