nnjeim / world

A Laravel package which provides a list of the countries, states, cities, currencies, timezones and languages.
MIT License
748 stars 105 forks source link

Cities Table is not seeding #1

Closed claytongf closed 2 years ago

claytongf commented 2 years ago

Laravel Version: 8.65 Nnjeim/world: ^1.0

While using php artisan db:seed --class="WorldSeeder", it takes less than expected which means, nothing was seeded. However, I've found that after comment the line 30, the seed works without cities table. line 30: $this->data['cities'] = json_decode(File::get(__DIR__ . '/../../resources/json/cities.json'), true); I was thinking that the file cities.json is very big. But, changing configurations in php.ini, such as upload_max_filesize and post_max_size to greater than the size of the file still not working. What should I do to make the seed works?

nnjeim commented 2 years ago

@claytongf Hi, the only thing i can think about is the memory allocated to php try to increase the memory_limit in php.ini. on my local machine i have 2048M allocated and it works fine.

claytongf commented 2 years ago

@nnjeim Hi. Thanks for your response. Changing the memory allocated in php.ini to 2048M worked fine! Thank you! I'm just worried about seeding all the data in production. You think there is a way to seed them allocating less memory?

nnjeim commented 2 years ago

@claytongf Hi again, the seeder is only needed to build up the database tables, once done , the php resources can be reduced. I will try to set the memory limit in the seeder itself in the coming version ini_set('memory_limit', '2G'). Another solution might be to array_chunk the cities array.