Forum

Ask, reply and learn. Join the community of Akaunting.

New Discussion

Error Class 'Faker\Factory' not found

Marcel (desplega)   ( User )

Commented 2 years ago

Hi,

I installed the Employees App. I am trying to populate employees using Factories. This is my call inside tinker:
>>> Modules\Employees\Models\Employee::factory()->create();

And this is the error I get:
PHP Error: Class 'Faker\Factory' not found in /var/www/html/akaunting/vendor/laravel/framework/src/Illuminate/Database/DatabaseServiceProvider.php on line 91

What am I doing wrong?

Thanks in advance!

Marcel (desplega)   ( User )

Commented 2 years ago

Hi again, I found the solution.
The problem was that I was using 'production' environment, and in that case the Faker\Factory class is not available.
The solution consists on:
1. Change .env file in order to change the environment to 'testing':
APP_ENV=production ----> APP_ENV=testing
2. Run 'composer install' from Akaunting project root folder. It will reinstall all packages, this time including Faker\Factory class.

Now, we can populate the database using Factory in Tinker:
$ php artisan tinker
Psy Shell v0.10.8 (PHP 7.4.3 — cli) by Justin Hileman
>>> $post = Modules\MyBlog\Models\Post::factory()->make();
PHP Deprecated: Since fakerphp/faker 1.14: Accessing property "boolean" is deprecated, use "boolean()" instead. in /var/www/html/akaunting/vendor/symfony/deprecation-contracts/function.php on line 25
=> Modules\MyBlog\Models\Post {#6498
company_id: 1,
name: "Saepe ex saepe.",
description: "Eligendi quia soluta nobis labore. Non dolor qui animi nobis.",
enabled: 0,
}
>>>

Note: You can ignore the warning, however it would be good to fix it in the MyBlog module.

Marcel (desplega)   ( User )

Commented 2 years ago

Update:
You should use
APP_ENV=local
instead of 'production', but not 'testing', which is not supported by Laravel.

John Cena   ( User )

Commented 1 year ago

I was able to deploy the same project locally with out any problem and composer update on forge also runs https://uk.bestessays.com/buy_essays.html successfully and i can see the Error Class 'Faker\Factory' not found. ou need to run Run 'composer install' from Akaunting project root folder. It will reinstall all packages, this time including Faker\Factory class.

Please login or register to leave a response.

Showing 1 to 4 of 4 discussions