Change factories path in Laravel 5.2
<p>I'm trying to change my factories directory to a custom path, so I'm using this as I saw in a <a href="https://laracasts.com/discuss/channels/laravel/l51-how-to-change-factories-path-when-using-model-factories" rel="nofollow">laracasts thread</a>:</p>

<pre><code>use Illuminate\Database\Eloquent\Factory as Factory;

class FactoryServiceProvider extends ServiceProvider
{
    public function register()
    {
            $this-&gt;app-&gt;singleton(Factory::class, function () {
                return Factory::construct(new Faker\Generator, app_path() .'/Core/Database/Factories');
            });
    }
}
</code></pre>

<p>The new path works, my factory files inside the new directory are loaded. But now when I try to use the factory from seeders on <code>php artisan migrate:refresh --seed</code> I'm getting</p>

<blockquote>
  <p>[InvalidArgumentException] Unknown formatter "name"</p>
</blockquote>

<p>from the $faker instance inside the factory definition:</p>

<pre><code>$factory-&gt;define(User::class, function (Faker\Generator $faker) {
    return[
        'name' =&gt; $faker-&gt;name,
        'email' =&gt; $faker-&gt;freeEmail,
        'password' =&gt; bcrypt($faker-&gt;word),
        'remember_token' =&gt; str_random(10)
    ];
});
</code></pre>

<p>This error appears with all the formatters, not just with name.</p>

<p>Where is the problem? The factory works fine before I change the path.</p>