Laravel中咱們登陸服務器經過 Tinker 手動建立後臺管理用戶

Laravel中咱們能夠登陸到服務器經過 Tinker 手動建立後臺用戶

laravel中tinker命令的做用是用來調試laravel,能夠打印變量或對象信息,顯示函數代碼,對數據庫寫入和查詢數據。輸入help能夠查看幫助信息。php

tinker命令的啓動方式爲php artisan tinker,運行後出現的提示符爲tinker的提示符,用於經過命令行與應用進行交互。laravel

下面咱們開始建立後臺用戶:shell

php artisan tinker 

這裏有一個報錯: ErrorException  : exec() has been disabled for security reasons數據庫

解決:打開php.ini文件,搜索 disable_functions,找到以下相似內容:  disable_functions=passthru,exec,system,chroot,scandir,chgrp,chown,shell_exec,proc_get_status,proc_open,popen,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server 找到exec並刪除而後重啓php服務。再次輸入php artisan tinker服務器

$user = new App\User();
$user->name = 'jiji';
$user->password = bcrypt('123456');
$user->email = 'hiit@vip.qq.com';
$user->save();

把上面代碼複製到Tinker中socket

 

密碼除了使用bcrypt()加密, 還能夠使用Hash::mark()。函數

$user->password = Hash::make('123456');

好了,如今就能夠登陸後臺了。工具

Laravel Tinker是一款工具,能夠幫助咱們輕鬆地與咱們的應用程序進行交互,比PHP內置的強。加密

相關文章
相關標籤/搜索