我需要将遗留系统迁移到Laravel。我使用的是PHP5.6,我们有一个使用会话和cookie的登录系统来个性化一些用户内容。好吧,我想迁移我的系统的一些部分,我认为第一个将是登录,我认为我需要在Laravel和旧的PHP之间共享登录,但什么是更好的方法呢?用户密码没有进入bcrypt加密,我需要将“登录”共享到旧系统页面,而新页面迁移到Laravel。
谢谢
发布于 2020-06-01 22:07:44
创建新的ServiceProvider,如LegacyHashProvider
namespace App\Providers;
use App\Services\LegacyHasher;
use Illuminate\Support\ServiceProvider;
class LegacyHashProvider extends ServiceProvider
{
public function register()
{
$this->app->singleton('hash', function ($app) {
return new LegacyHasher($app);
});
}
public function provides()
{
return ['hash'];
}
}创建一个实现Illuminate\Contracts\Hashing\Hasher接口的类LegacyHasher。写下你的方法(覆盖),比如;
public function make($value, array $options = [])
{
return hash('sha512', $value); // this will be your legacy hashing system
}导航到config/app.php并用App\Providers\LegacyHashProvider替换Illuminate\Hashing\HashServiceProvider::class,它应该已经准备好使用您的遗留登录系统了。
https://stackoverflow.com/questions/62133877
复制相似问题