- How do I install this package for Laravel user migration?
- Run `composer require selfsimilar/drupal7_password_hasher` and wrap the package in a Laravel-compatible class (e.g., implementing `HashInterface`). No service provider is included, so manual binding is required in your `AppServiceProvider`. Test with a sample Drupal 7 hash first to confirm compatibility.
- Can this package handle password resets for migrated Drupal 7 users?
- No, this package only handles hashing/verification. For password resets, you’ll need to integrate it with Laravel’s `Password::reset()` or manually validate tokens against the Drupal 7 hash format. Ensure your reset flow checks the hash prefix (e.g., `$2y$` for phpass) before processing.
- What Laravel versions does this package support?
- The package works with Laravel 5.5+ and PHP 7.4+, as it relies on Drupal 7’s minimum requirements. For older Laravel versions (e.g., 5.x), you may need to polyfill `HashInterface` or use a custom guard. Test thoroughly with your target Laravel version.
- Is this package secure for new user registrations in Laravel?
- No. Drupal 7’s hashing (SHA-512 + salt) is outdated compared to Laravel’s default (Bcrypt/Argon2). Use this **only** for migrating existing Drupal 7 users. For new users, always use Laravel’s `Hash::make()` with a modern algorithm.
- How do I integrate this with Laravel’s authentication system?
- Create a custom guard or extend Laravel’s `Hash` facade to delegate Drupal 7 hashes to this package. Override `retrieveByCredentials()` in your `AuthServiceProvider` to handle legacy hashes. Example: Check if the stored hash starts with `$2y$` (Drupal 7 phpass format) and route it to the Drupal hasher.
- What if my Drupal 7 site uses a custom `password_count_log2` value?
- Pass the value to the `Hasher` constructor (default is 15). Retrieve it from Drupal 7 via `drush variable-get password_count_log2` or check your `settings.php`. Mismatched iteration counts will cause verification failures, even for correct passwords.
- Are there alternatives to this package for Drupal 7 migrations?
- Yes. Consider [`hautelook/phpass`](https://github.com/hautelook/phpass), which is more actively maintained and supports Drupal 7/8 hashes. For Laravel, you could also manually implement phpass logic or use Laravel’s `Hash` facade with a custom driver. Evaluate based on your need for Drupal 7 *specific* compatibility.
- How do I test if this package works with my existing Drupal 7 hashes?
- Export a few Drupal 7 user passwords (e.g., from `users` table) and verify them using the package’s `CheckPassword()` method. Compare results against Drupal 7’s native `user_pass()` function or a test environment. Example: `DrupalHasher::CheckPassword('test', '$2a$08$hashedString')`.
- Will this package work with Laravel’s Eloquent or database migrations?
- No direct integration exists. Use it in a console command or seeder to rehash imported users. Example: `User::where('imported_from', 'drupal7')->each(fn($user) => $user->password = DrupalHasher::hash($user->plain_password));`. Avoid storing Drupal 7 hashes long-term; migrate to Laravel’s format ASAP.
- What happens if I mix Drupal 7 and Laravel hashes in the same database?
- Avoid this if possible. Use a column like `password_format` (e.g., `drupal7` or `laravel`) to distinguish hashes. In your auth logic, route verification to the correct hasher based on this flag. Example: `if (str_starts_with($hash, '$2y$')) { use DrupalHasher; } else { use Hash::check(); }`