Laravel无法从Acme目录中自动加载模型?

in my Laravel app I have created Acme\fooDir directory inside app directory

i am trying to call a model -"barModel"- from within the fooDir

 //app/Acme/fooDir/test.php 
 $barM = new barModel;

but i am getting this error

        Class 'Acme\fooDir\barModel' not found

here is my app structure

  app
  -app/Acme
  --app/Acme/fooDir
  ---app/Acme/fooDir/test.php (this is the file that could load the barModel)
  -app/models
  --app/model/barModel.php (this is the model i am trying to use)

I have added autoload in composer.json

"autoload": {
    "classmap": [
        "app/commands",
        "app/controllers",
        "app/models",
        "app/database/migrations",
        "app/database/seeds",
        "app/tests/TestCase.php"
    ],
    "psr-0": 
    { 
        "Acme": "app/"           
    }

and I have ran the command

composer dump-autoload -o

and

php artisan dump-autoload

but the problem not solved and i am still getting the same error

    Class 'Acme\fooDir\barModel' not found

any idea?

When using namespace all your classes are called within that namespace.

If you want to use barModel in Acme/fooDir/test.php your will need to use use barModel; just after your namespace row.

<?php
namespace Acme\fooDir;

use barModel;

class test {

}

Two things.

1, Have you namespaced your classes ie,

<?php namespace Acme\FooDir;

class Test ...

2, Are you using use in your class

<?php namespace Acme\FooDir;

use \BarModel

class Test ...

?

Would this do the trick for you.

 $barM = new \barModel;

PHP namespaces and importing