<?php namespace Illuminate\Encryption; use RuntimeException; use Illuminate\Support\ServiceProvider; class EncryptionServiceProvider extends ServiceProvider {// Eccryption Service Provider extends Services Provider /** * Register the service provider. * * @return void * * @throws \RuntimeException */ public function register() {// register this function $this->app->singleton('encrypter', function ($app) { $config = $app->make('config')->get('app');// who is app to make and get $key = $config['key'];// set config key $cipher = $config['cipher'];// set config cipher if (Encrypter::supported($key, $cipher)) {//determine is support this way return new Encrypter($key, $cipher); } elseif (McryptEncrypter::supported($key, $cipher)) { return new McryptEncrypter($key, $cipher); } else { throw new RuntimeException('No supported encrypter found. The cipher and / or key length are invalid.'); } });// i hate this function, too simple } }
[李景山php]每天laravel-20160826|EncryptionServiceProvider
原创
©著作权归作者所有:来自51CTO博客作者lijingsan1的原创作品,请联系作者获取转载授权,否则将追究法律责任
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章