尊龙凯时人生就是博

laravelµÇ¼ʵÏÖ

laravelÊÇÒ»¸öÊ¢ÐеÄphp¿ò¼Ü£¬ËüÌṩÁËÐí¶àÇ¿Ê¢µÄ¹¤¾ßºÍ¹¦Ð§£¬×ÊÖú¿ª·¢ÕßÇáËɵع¹½¨webÓ¦ÓóÌÐò¡£ÆäÖУ¬ÊµÏֵǼ¹¦Ð§ÊÇ¿ª·¢Ó¦ÓóÌÐòµÄÖ÷ÒªÒ»²½¡£±¾ÎĽ«ÏÈÈÝÔõÑùÔÚlaravelÖÐʵÏֵǼ¹¦Ð§¡£

×°ÖÃLaravel

Laravel¿ÉÒÔͨ¹ýComposer×°Öã¬ComposerÊÇÒ»¸öPHPÒÀÀµÖÎÀí¹¤¾ß¡£×°ÖÃComposer£¬ÊäÈëÒÔÏÂÏÂÁ

curl -sS https://getcomposer.org/installer | php
mv composer.phar /usr/local/bin/composer

µÇ¼ºó¸´ÖÆ

×°ÖÃÍê³Éºó£¬Ê¹ÓÃÒÔÏÂÏÂÁîÀ´½¨Éè Laravel Ó¦ÓóÌÐò¡£

composer create-project --prefer-dist laravel/laravel projectname

µÇ¼ºó¸´ÖÆ

Êý¾Ý¿âÉèÖÃ

ÔÚʹÓÃLaravelµÄÈÏ֤ϵͳ֮ǰ£¬ÐèÒªÉèÖÃÊý¾Ý¿â¡£·­¿ª .env Îļþ£¬¸ü¸ÄÒÔÏÂʾÀýÖеÄÊý¾Ý¿âÅþÁ¬ÉèÖá£

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=mydatabase
DB_USERNAME=root
DB_PASSWORD=

µÇ¼ºó¸´ÖÆ

ÌìÉúÓû§ÈÏ֤ϵͳ

ÔËÐÐÒÔÏÂÏÂÁîÌìÉú Laravel µÄÓû§ÈÏ֤ϵͳ¡£

php artisan make:auth

µÇ¼ºó¸´ÖÆ

Õ⽫½¨ÉèÒ»¸öÓû§×¢²á¡¢µÇ¼ºÍ×¢ÏúµÄ»ù±¾ÊÓͼºÍ¿ØÖÆÆ÷¡£

½¨ÉèÓû§Ä£×Ó

½ÓÏÂÀ´£¬ÐèÒª½¨ÉèÒ»¸öÓû§Ä£×Ó£¬LaravelĬÈÏÌṩµÄÓû§Ä£×ÓÊÇAppUser£¬¿ÉÒÔʹÓÃÒÔÏÂÏÂÁÉè¡£

php artisan make:model User

µÇ¼ºó¸´ÖÆ

×¢²áºÍµÇ¼ÑéÖ¤

×¢²áÑéÖ¤£º

public function store(Request $request)
{
    $this->validate($request, [
        'name' => 'required',
        'email' => 'required|email|unique:users,email',
        'password' => 'required|min:6|confirmed',
    ]);
    $user = User::create([
        'name' => $request['name'],
        'email' => $request['email'],
        'password' => bcrypt($request['password']),
    ]);
    Auth::login($user);
    return redirect()->route('dashboard');
}

µÇ¼ºó¸´ÖÆ

µÇ¼ÑéÖ¤£º

public function login(Request $request)
{
    $this->validate($request, [
        'email' => 'required|email',
        'password' => 'required|min:6',
    ]);
    $credentials = [
        'email' => $request['email'],
        'password' => $request['password'],
    ];
    if (Auth::attempt($credentials)) {
        return redirect()->intended('dashboard');
    } else {
        return redirect()->back()->withInput($request->only('email', 'remember'));
    }
}

µÇ¼ºó¸´ÖÆ

ÒÔÉÏ´úÂëÖУ¬attemptÒªÁ콫ÑéÖ¤Óû§Æ¾Ö¤£¬ÈôÊÇͨ¹ýÑéÖ¤£¬½«»á½«Óû§×´Ì¬Í¨¹ýsessionÉúÑÄ£¬²¢ÇÒ¿ÉÒÔʹÓÃAuth::checkÒªÁì¼ì²éÓû§ÊÇ·ñÒѵǼ¡£

ÖÐÐļþ

ÖÐÐļþÌṩÁ˶ÔÓ¦ÓóÌÐòµÄ½øÒ»²½¿ØÖƺͱ£»¤¡£LaravelÒѾ­Ô¤½ç˵ÁËÐí¶àÖÐÐļþ£¬°üÀ¨ÑéÖ¤Óû§ÊÇ·ñµÇ¼µÄÖÐÐļþ¡£

ÔÚÓ¦ÓóÌÐòÖÐÌí¼ÓÈÏÖ¤ÖÐÐļþ£¬²¢½«ÆäÓ¦ÓÃÓÚÐèÒª±£»¤µÄ·ÓÉ£º

Route::middleware(['auth'])->group(function () {
    Route::get('/dashboard', 'DashboardController@index')->name('dashboard');
});

µÇ¼ºó¸´ÖÆ

Ç¿ÖÆʹÓà HTTPS

ÔÚLaravelÖУ¬¿ÉÒÔÇáËɵؽ«Ó¦ÓóÌÐòÇ¿ÖÆʹÓÃHTTPS£º

ÔÚ.envÖÐÌí¼ÓÒÔÏÂÐУº

APP_ENV=production
APP_URL=https://example.com

µÇ¼ºó¸´ÖÆ

È»ºó£¬·­¿ªAppServiceProviderÀ࣬Ìí¼ÓÒÔÏÂÐУº

public function boot()
{
    if (config('app.env') === 'production') {
        URL::forceScheme('https');
    }
}

µÇ¼ºó¸´ÖÆ

Õ⽫ǿÖƽ«Ó¦ÓóÌÐòµÄURLÁ´½Óת»»ÎªHTTPSЭÒé¡£

×ܽá

ÖÁ´Ë£¬±¾ÎÄÏÈÈÝÁËÔõÑùÔÚLaravelÖÐʵÏֵǼ¹¦Ð§£¬°üÀ¨×°ÖÃLaravel¡¢ÉèÖÃÊý¾Ý¿â¡¢ÌìÉúÓû§ÈÏ֤ϵͳ¡¢½¨ÉèÓû§Ä£×Ó¡¢×¢²áºÍµÇ¼ÑéÖ¤¡¢ÖÐÐļþºÍÇ¿ÖÆʹÓÃHTTPS¡£Ê¹Óñ¾ÎÄÌṩµÄ°ì·¨À´ÊµÏÖLaravelµÄµÇ¼¹¦Ð§£¬¿ÉÒÔ×ÊÖúÄú¹¹½¨³öÔ½·¢Çå¾²ºÍ¹¦Ð§¸»ºñµÄÓ¦ÓóÌÐò¡£

ÒÔÉϾÍÊÇlaravelµÇ¼ʵÏÖµÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

ÃâÔð˵Ã÷£ºÒÔÉÏչʾÄÚÈÝȪԴÓÚÏàÖúýÌå¡¢ÆóÒµ»ú¹¹¡¢ÍøÓÑÌṩ»òÍøÂçÍøÂçÕûÀí£¬°æȨÕùÒéÓë±¾Õ¾Î޹أ¬ÎÄÕÂÉæ¼°¿´·¨Óë¿´·¨²»´ú±í尊龙凯时人生就是博ÂËÓÍ»úÍø¹Ù·½Ì¬¶È£¬Çë¶ÁÕß½ö×ö²Î¿¼¡£±¾ÎĽӴýתÔØ£¬×ªÔØÇë˵Ã÷À´ÓÉ¡£ÈôÄúÒÔΪ±¾ÎÄÇÖÕ¼ÁËÄúµÄ°æȨÐÅÏ¢£¬»òÄú·¢Ã÷¸ÃÄÚÈÝÓÐÈκÎÉæ¼°ÓÐÎ¥¹«µÂ¡¢Ã°·¸Ö´·¨µÈÎ¥·¨ÐÅÏ¢£¬ÇëÄúÁ¬Ã¦ÁªÏµ尊龙凯时人生就是博ʵʱÐÞÕý»òɾ³ý¡£

Ïà¹ØÐÂÎÅ

ÁªÏµ尊龙凯时人生就是博

13452372176

¿É΢ÐÅÔÚÏß×Éѯ

ÊÂÇéʱ¼ä£ºÖÜÒ»ÖÁÖÜÎ壬9:30-18:30£¬½ÚãåÈÕÐÝÏ¢

QR code
sitemap¡¢ÍøÕ¾µØͼ