Skip to content

๐ŸŒฑ Seeders โ€‹

Popule seu banco de dados com paรญses, regiรตes e traduรงรตes em poucos comandos โ€” do ambiente local ร  produรงรฃo. ๐Ÿš€

After migrations are in place, Laravel Countries populates countries, regions, and translations through language seeders. This page covers the recommended install flow, production deployment, and how to run seeders manually when needed.


๐Ÿ“š Table of contents โ€‹


๐Ÿš€ Quick install (local development) โ€‹

bash
php artisan w-countries:install

๐Ÿ’ก Tip: the interactive installer walks you through migrations, language selection, and config publishing โ€” perfect for getting started locally with zero guesswork.


๐Ÿญ Production deployment (Laravel 11, 12, and 13) โ€‹

In production, Laravel requires explicit confirmation before running seeders. No worries โ€” the package handles this automatically whenever you use the built-in commands with --force. โœ…


1๏ธโƒฃ Full non-interactive install โ€‹

Use this when you want migrations + seeders + config publishing in a single step:

bash
php artisan w-countries:install --force
๐ŸŽฏ GoalCommand
Seed English only (default)php artisan w-countries:install --force
Seed specific languagesphp artisan w-countries:install --force --languages=en,pt,es
Seed all available languagesphp artisan w-countries:install --force --languages=all

2๏ธโƒฃ Seed only (migrations already deployed) โ€‹

๐Ÿ”ฅ The most common production scenario: migrations ran during deploy, and you only need the data.

bash
php artisan w-countries:seed
๐ŸŽฏ GoalCommand
Seed specific languagesphp artisan w-countries:seed --languages=en,pt,es
Seed all languagesphp artisan w-countries:seed --all

3๏ธโƒฃ Manual db:seed commands โ€‹

If you prefer running Laravel's native seeder command directly, always pass --force in production. Replace mysql with your connection name when using a custom database (see Supported Databases).

๐Ÿ‡ฌ๐Ÿ‡ง English โ€” required, includes all countries and regions:

bash
php artisan db:seed --class="Lwwcas\LaravelCountries\Database\Seeders\LwwcasDatabaseSeeder" --database=mysql --force
๐ŸŒ Click to expand โ€” all additional language seeders
LanguageLocaleSeeder class
๐Ÿ‡ธ๐Ÿ‡ฆ ArabicarLwwcas\LaravelCountries\Database\Seeders\Languages\ArabicLanguageSeeder
๐Ÿ‡ณ๐Ÿ‡ฑ DutchnlLwwcas\LaravelCountries\Database\Seeders\Languages\DutchLanguageSeeder
๐Ÿ‡ซ๐Ÿ‡ท FrenchfrLwwcas\LaravelCountries\Database\Seeders\Languages\FrenchLanguageSeeder
๐Ÿ‡ฉ๐Ÿ‡ช GermandeLwwcas\LaravelCountries\Database\Seeders\Languages\GermanLanguageSeeder
๐Ÿ‡ฎ๐Ÿ‡น ItalianitLwwcas\LaravelCountries\Database\Seeders\Languages\ItalianLanguageSeeder
๐Ÿ‡ต๐Ÿ‡น PortugueseptLwwcas\LaravelCountries\Database\Seeders\Languages\PortugueseLanguageSeeder
๐Ÿ‡ท๐Ÿ‡บ RussianruLwwcas\LaravelCountries\Database\Seeders\Languages\RussianLanguageSeeder
๐Ÿ‡ช๐Ÿ‡ธ SpanishesLwwcas\LaravelCountries\Database\Seeders\Languages\SpanishLanguageSeeder
๐Ÿ‡น๐Ÿ‡ท TurkishtrLwwcas\LaravelCountries\Database\Seeders\Languages\TurkishLanguageSeeder

Example for Portuguese ๐Ÿ‡ต๐Ÿ‡น:

bash
php artisan db:seed --class="Lwwcas\LaravelCountries\Database\Seeders\Languages\PortugueseLanguageSeeder" --database=mysql --force

๐Ÿ’ก Shortcut

Run php artisan w-countries:seed --show-commands to print the full list of manual commands for your configured database connection.


โš ๏ธ Why --force is required in production โ€‹

On Laravel 11, 12, and 13, the db:seed command asks for confirmation whenever APP_ENV=production. If a command runs seeders silently โ€” without showing that prompt โ€” the process hangs until input is received. ๐Ÿ›‘

โœ… The fix: every seed command in this package passes --force automatically, so production deploys complete without any interaction.


๐Ÿ”ง Custom database connection โ€‹

When using a dedicated connection (for example countries), pass it to every command:

bash
php artisan w-countries:seed --languages=en,pt

The connection is read from config/w-countries.php (the driver key). Manual commands must use that same value for --database:

bash
php artisan db:seed --class="Lwwcas\LaravelCountries\Database\Seeders\LwwcasDatabaseSeeder" --database=countries --force

CommandPurpose
๐Ÿงฉ w-countries:installFull setup: migrations, seeders, config
๐ŸŒฑ w-countries:seedRun language seeders only
๐ŸŒ w-countries:languagesInstall or uninstall languages interactively

โœ… Cheat sheet โ€‹

๐Ÿ“Ž Click to see every command at a glance
bash
# Local development
php artisan w-countries:install

# Production โ€” full install
php artisan w-countries:install --force
php artisan w-countries:install --force --languages=en,pt,es
php artisan w-countries:install --force --languages=all

# Production โ€” seed only
php artisan w-countries:seed
php artisan w-countries:seed --languages=en,pt,es
php artisan w-countries:seed --all

# Manual db:seed
php artisan db:seed --class="Lwwcas\LaravelCountries\Database\Seeders\LwwcasDatabaseSeeder" --database=mysql --force

# Custom database connection
php artisan db:seed --class="Lwwcas\LaravelCountries\Database\Seeders\LwwcasDatabaseSeeder" --database=countries --force

# Show all manual commands
php artisan w-countries:seed --show-commands

Precisa de ajuda? Abra uma issue no GitHub ๐Ÿ’ฌ

Released under the MIT License.