Closed balodoc closed 8 years ago
Need help with this too!
This is very strange. I spend 6 hours in finding that issue but unable to resolve that. I also deployed it on other servers but only heroku is not reading the faker class.
Even I add the "fzaninotto/faker" in the require section in composer.json.
Any one have done it. Please reply.
[Symfony\Component\Debug\Exception\FatalThrowableError]
Class 'Faker\Factory' not found
@rolandtacadena How do you find the solution of this problem?
in composer.json change : "fzaninotto/faker" of "require-dev" for "require"
Thanks @Carlos-Alves !
@Carlos-Alves I use your method but don't solve problem, why?
"require": { "php": ">=7.0.0", "fideloper/proxy": "~3.3", "laravel/framework": "5.5.*", "laravel/tinker": "~1.0", "overtrue/laravel-lang": "~3.0", "fzaninotto/faker": "~1.4" }, "require-dev": { "filp/whoops": "~2.0", "mockery/mockery": "0.9.*", "phpunit/phpunit": "~6.0" },
Hi @RoseEnd in your project folder login to heroku, run heroku run bash
Hi @RoseEnd in your project folder login to heroku: heroku login in composer.json change : "fzaninotto/faker" of "require-dev" for "require" commit to your heroku branch and push: git push heroku master or if you use other branch name other than "master" git push heroku your_branch:master run heroku run bash then run composer install
Then run php artisan migrate:refresh --seed --force and lets see.
On Wed, Aug 23, 2017 at 1:12 PM, Roland Tacadena tacadenaroland@gmail.com wrote:
Hi @RoseEnd in your project folder login to heroku, run heroku run bash
-- Roland C. Tacadena
I did it but i️s not workin... :(
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"type": "project",
"require": {
"php": ">=7.0",
"appstract/laravel-opcache": "^1.2",
"artesaos/seotools": "^0.10.0",
"backup-manager/laravel": "^1.2",
"filp/whoops": "^2.1",
"laravel/framework": "5.5.*",
"laravel/tinker": "~1.0",
"laravelcollective/html": "^5.3.0",
"league/flysystem-aws-s3-v3": "^1.0",
"league/flysystem-sftp": "^1.0",
"spatie/laravel-sitemap": "^3.1",
"srmklive/flysystem-dropbox-v2": "^1.0",
"uxweb/sweet-alert": "^1.4",
"yajra/laravel-datatables-oracle": "^8.0",
"fzaninotto/faker": "~1.4"
},
"require-dev": {
"barryvdh/laravel-debugbar": "^3.0",
"mockery/mockery": "0.9.*",
"phpunit/phpunit": "~6.0"
},
"autoload": {
"classmap": [
"database/seeds",
"database/factories"
],
"psr-4": {
"App\\": "app/"
}
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/"
}
},
"scripts": {
"post-root-package-install": [
"php -r \"file_exists('.env') || copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"php artisan key:generate"
],
"post-install-cmd": [
"Illuminate\\Foundation\\ComposerScripts::postInstall",
"php artisan optimize"
],
"post-update-cmd": [
"Illuminate\\Foundation\\ComposerScripts::postUpdate",
"php artisan optimize"
]
},
"config": {
"preferred-install": "dist",
"sort-packages": true,
"optimize-autoloader": true
}
}
git add .
git commit -am "changes"
git push heroku master
...
Migrations work successfully but db:seed fail:
heroku php artisan db:seed
--> FAIL:
[Symfony\Component\Debug\Exception\FatalThrowableError]
Class 'Faker\Factory' not found
Folders:
Model:
$factory->define(App\User::class, function (Faker\Generator $faker) {
static $password;
return [
'name' => $faker->name,
'email' => $faker->unique()->safeEmail,
'password' => $password ?: $password = bcrypt('secret'),
'remember_token' => str_random(10),
];
});
DatabaseSeeders:
use Illuminate\Database\Seeder;
class DatabaseSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
// php artisan migrate:refresh --seed
$this->call(UsersTableSeeder::class);
factory(App\Log::class, 100)->create();
factory(App\Tag::class, 10)->create();
factory(App\Post::class, 10)->create();
factory(\App\Maintenance::class, 1)->create();
factory(\App\Post_tag::class, 20)->create();
}
}
composer update
(this will update composer.lock file)"fzaninotto/faker" of "require-dev" for "require"
git push heroku master
heroku run bash
composer install
php artisan db:seed
this really works
If for any reason you are still having issue with this
Do the following
Change "fzaninotto/faker" of "require-dev" for "require" in your composer.json file
Run composer update - this will sync your composer.json and composer.lock files
Add and commit your changes with git - git add . and git commit -m "type commit message here"
update your upstream by running "git push heroku master"
open heroku console with "heroku run bash"
Now run your seeder with "php artisan db:seed"
I follow the steps and failed at composer update. It says "PHP Fatal error: Allowed memory size of # bytes exhausted".
Simply execute in your Heroku console
composer install --dev
to install require-dev dependencies
php artisan db:seed
to run your seeders
Alternatively, if you do not have an NAT Gateway protecting your database and you can access it by IP, you can just change your local .env
file to the DB creds from Vapor (see below for example) and then run php artisan db:seed
to run your app locally and seed your remote database. If you're running Laravel via sail, then the command would be sail artisan db:seed
.
Don't forget to change your .env back to point to your local database after, if necessary.
Sample .env
:
DB_CONNECTION=mysql
DB_HOST={{host}}
DB_PORT=3306
DB_DATABASE=vapor
DB_USERNAME=vapor
DB_PASSWORD={{pass}}
I successfully deployed a laravel in production in Heroku but when I run 'heroku run php artisan db:seed' I got this error:
[Symfony\Component\Debug\Exception\FatalThrowableError] Fatal error: Class 'Faker\Factory' not found
Does any one of you get the error deploying on heroku?
I use cleardb add ons.
When I run 'heroku run php artisan migrate' in production it all works fine only the heroku run php artisan db:seed' has error. It all works on development side, but in production I got the error.
It seems like in the Faker library id not loaded in the DatabaseSeeder class? Is there a problem on my composer not loading the Faker library? or permission on vendor folder?
I will appreciate any help. Thanks.