Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This is not a Laravel 'problem', this is something that will work, exactly the same way, on every application that uses Composer.</p> <p>If your classes are following the psr-0 rules (directory structure matters!), you can configure it in your composer.json </p> <pre><code>{ "autoload": { "psr-0": {"MyNamespace\\": "app/models"} } } </code></pre> <p>Execute </p> <pre><code>composer dump-autoload </code></pre> <p>Once and it it will show in your autoload_namespaces.php. After that Composer will be able to find your classes by its namespaces, no need to <code>dump-autoload</code> again.</p> <p>To explain better how it works. If you do</p> <pre><code>"psr-0": {"MyNamespace\\": "app/models"} </code></pre> <p>You must use it this way:</p> <pre><code>$user = new MyNamespace\User.php </code></pre> <p>Because Composer adds your namespace to the end of your namespace path and it will expect to find User.php in</p> <pre><code>/var/www/yourappdir/app/models/MyNamespace/User.php </code></pre> <p>So, by doing</p> <pre><code>"psr-0": { "App\\Models\\": "" } </code></pre> <p>You are telling Composer that ALL <code>/var/www/yourappdir/App/Models</code> subfolders can contain namespaced files of the App\Models namespace. And you'll be able to address files like:</p> <pre><code>$user = new App\Models\User.php $user = new App\Models\MyNamespace\User.php $user = new App\Models\MyNamespace\Foo\Bar\User.php </code></pre> <p>And if you do</p> <pre><code>"psr-0": { "App\\Foo": "" } </code></pre> <p>Composer will be able to address those namespaces</p> <pre><code>/var/www/yourappdir/App/Foo /var/www/yourappdir/App/FooBar /var/www/yourappdir/App/Foo/Bar /var/www/yourappdir/App/Foo/Bar/Baz </code></pre> <p>But if you do</p> <pre><code>"psr-0": { "App\\Foo\\": "" } </code></pre> <p>It will be able to address just</p> <pre><code>/var/www/yourappdir/App/Foo /var/www/yourappdir/App/Foo/Bar /var/www/yourappdir/App/Foo/Bar/Baz </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload