Installation
Requirements
Before installing Laravel Language, make sure you have:
- PHP >= 8.2
- Laravel >= 9.19 (10/11/12 supported)
- Composer
- jobmetric/laravel-package-core ^1.31
- spatie/laravel-query-builder ^6.3
- jobmetric/multi-calendar ^1.2
- jobmetric/laravel-event-system ^2.7
Install via Composer
Run the following command to pull in the latest version:
composer require jobmetric/laravel-language
Service Provider
Laravel Package Auto-Discovery will automatically register the service provider. If you're using Laravel < 5.5 or have disabled auto-discovery, manually register the provider in config/app.php:
'providers' => [
// ...
JobMetric\Language\LanguageServiceProvider::class,
],
Publish Configuration
After installation, publish the configuration file:
php artisan vendor:publish --provider="JobMetric\Language\LanguageServiceProvider" --tag="language-config"
This will create a config/language.php file where you can customize package settings.
Publish Migrations
Publish and run the migration to create the languages table:
php artisan vendor:publish --provider="JobMetric\Language\LanguageServiceProvider" --tag="language-migrations"
php artisan migrate
Publish Translations
If you want to customize translation files:
php artisan vendor:publish --provider="JobMetric\Language\LanguageServiceProvider" --tag="language-translations"
Publish Assets
If you want to use flag images:
php artisan vendor:publish --provider="JobMetric\Language\LanguageServiceProvider" --tag="language-assets"
Verify Installation
To verify the package is installed correctly, you can test adding a language:
use JobMetric\Language\Facades\Language;
// Add a language from predefined data
Language::addLanguageData('fa');
// Or create manually
$language = Language::store([
'name' => 'English',
'flag' => 'us',
'locale' => 'en',
'direction' => 'ltr',
'calendar' => 'gregorian',
'first_day_of_week' => 1,
'status' => true,
]);
// If no errors occurred, installation is successful!
Next Steps
Now that you've installed Laravel Language, you can:
- Learn about Language Service
- Explore real-world examples
- Check out the complete API reference
Troubleshooting
Migration Errors
If you get migration errors:
- Make sure all dependencies are installed
- Check that the migrations table exists
- Run
php artisan migrate:statusto check migration status - Ensure database connection is configured correctly
Service Methods Not Found
If you get "Method not found" errors:
- Make sure the package is properly installed via Composer
- Run
composer dump-autoload - Clear any opcode cache (OPcache) if enabled
- Verify the facade is properly imported
Validation Rule Errors
If validation rules don't work:
- Ensure the rules are properly imported
- Check that the language table exists and has data
- Verify locale codes match your language data
Events Not Firing
If events are not firing:
- Ensure
laravel-event-systemis properly installed - Check that events are registered in the event system
- Verify event listeners are properly configured