尊龙凯时人生就是博

laravel Ôõôд¿ØÖÆÆ÷

laravelÊÇÒ»¸öÏÖ´úµÄphp web¿ª·¢¿ò¼Ü £¬ËüÌṩÁËÐí¶àÓÅÒìµÄ¹¦Ð§ºÍ¹¤¾ß £¬Ê¹¿ª·¢ÕßÄܹ»¿ìËٵع¹½¨¸ßÖÊÁ¿µÄwebÓ¦ÓóÌÐò¡£ÆäÖпØÖÆÆ÷ÊÇlaravelÖÐ×îÖ÷ÒªµÄ×é³É²¿·ÖÖ®Ò» £¬ËüÈÏÕæ´¦ÀíÓ¦ÓóÌÐòµÄÓªÒµÂß¼­¡£ÏÂÃæ¾ÍÀ´½²½²laravelÖпØÖÆÆ÷µÄ±àдҪÁì¡£

½¨Éè¿ØÖÆÆ÷

ÔÚLaravelÖÐ £¬½¨ÉèÒ»¸ö¿ØÖÆÆ÷ºÜÊǼòÆÓ £¬Ö»ÐèÒªÔÚ¿ØÖÆ̨ÉÏÊäÈëÒÔÏÂÏÂÁî¼´¿É£º

php artisan make:controller YourControllerName

µÇ¼ºó¸´ÖÆ

ÆäÖÐYourControllerNameÊÇÄãÏëÒª½¨ÉèµÄ¿ØÖÆÆ÷µÄÃû³Æ¡£

±àд¿ØÖÆÆ÷´úÂë

¿ØÖÆÆ÷´úÂëͨ³£Î»ÓÚapp/Http/ControllersĿ¼ÖÐ £¬·­¿ª¸Õ¸Õ½¨ÉèµÄ¿ØÖÆÆ÷Îļþ £¬Äã»á¿´µ½ÈçÏ´úÂ룺

<?php namespace App\Http\Controllers;

use Illuminate\Http\Request;

class YourControllerName extends Controller
{
    //
}

µÇ¼ºó¸´ÖÆ

ÆäÖÐnamespaceÊÇÃüÃû¿Õ¼ä £¬useÊÇÒýÓÃÀà¡£¼ÌÐøÁËControllerÀà £¬ControllerÀàÊÇLaravel¿ØÖÆÆ÷µÄ¸¸Àà £¬ÎªÎÒÃÇÌṩÁËÐí¶àĬÈÏÒªÁì £¬Èçview()¡¢json()¡¢redirect()µÈ¡£

ÏÖÔÚ £¬ÎÒÃǾͿÉÒÔ×îÏȱàдÎÒÃÇ×Ô¼ºµÄ¿ØÖÆÆ÷´úÂëÁË¡£ÒÔÒ»¸ö¼òÆÓµÄÀý×ÓΪÀý £¬¼ÙÉèÎÒÃÇҪʹÓÿØÖÆÆ÷À´²éÕÒºÍÏÔʾÓû§ÐÅÏ¢¡£ÄÇôÎÒÃÇ¿ÉÒÔÏò¿ØÖÆÆ÷ÀàÖÐÌí¼ÓÒÔÏ´úÂ룺

public function show($id)
{
    $user = User::find($id);
    return view('users.show', ['user' =&gt; $user]);
}

µÇ¼ºó¸´ÖÆ

ÔÚ´Ë´úÂëÖÐ £¬ÎÒÃǽç˵ÁËÒ»¸öÃûΪshow()µÄÒªÁì £¬²¢´ÓURLÖд«Èëid²ÎÊý¡£È»ºóÎÒÃÇʹÓÃUser::find($id)ÒªÁìÀ´ÅÌÎÊid¶ÔÓ¦µÄÓû§ÐÅÏ¢ £¬×îºóʹÓÃView()ÒªÁ콫Ïà¹ØµÄÓû§ÐÅϢת´ï¸øÊÓͼÎļþ£¨ÎļþλÓÚresources/views/users/show.blade.php£©¡£

·Óɽç˵

ÏÖÔÚÎÒÃÇÒѾ­½ç˵ÁË¿ØÖÆÆ÷ºÍÏà¹ØµÄÓªÒµÂß¼­´úÂë¡£ÎÒÃÇÐèÒªÈÃLaravelÓ¦ÓóÌÐòÖªµÀÔõÑù»á¼û¸Ã¿ØÖÆÆ÷ £¬Õâ¿ÉÒÔͨ¹ý·Óɽç˵ʵÏÖ¡£

ÔÚLaravelÖÐ £¬Â·Óɽç˵ͨ³£Î»ÓÚroutes/web.phpÎļþÖС£ÎÒÃÇ¿ÉÒÔÏò¸ÃÎļþÌí¼ÓÒÔÏ´úÂ룺

Route::get('users/{id}', 'YourControllerName@show');

µÇ¼ºó¸´ÖÆ

¸Ã´úÂë½ç˵ÁËÒ»¸öÃûΪshowµÄ·ÓÉ £¬½«»áÆ¥ÅäÒÔ/users¿ªÍ·µÄURL £¬²¢×ª´ïid²ÎÊý¸ø¿ØÖÆÆ÷µÄshow()ÒªÁì¡£

²âÊÔ

ÏÖÔÚÎÒÃÇÒѾ­Íê³ÉÁË¿ØÖÆÆ÷´úÂëµÄ±àдÒÔ¼°Â·ÓɵĽç˵ £¬½ÓÏÂÀ´ÈÃÎÒÃDzâÊÔÒ»ÏÂÎÒÃǵĿØÖÆÆ÷¡£

ÔÚ¿ØÖÆ̨ÉÏÆô¶¯¿ª·¢Ð§ÀÍÆ÷£º

php artisan serve

µÇ¼ºó¸´ÖÆ

È»ºóÔÚÄúµÄä¯ÀÀÆ÷Öлá¼û£º

http://localhost:8000/users/1

µÇ¼ºó¸´ÖÆ

Äã»á¿´µ½Ò»¸öÒ³ÃæÏÔʾÁËidΪ1µÄÓû§ÐÅÏ¢¡£ÖÁ´Ë £¬ÎÒÃǾÍÀֳɵؽ¨ÉèºÍʹÓÃÁËÒ»¸öLaravel¿ØÖÆÆ÷¡£

×ܽ᣺

ʹÓÃÏÂÁîÐпìËÙ½¨ÉèLaravel¿ØÖÆÆ÷¡£

±àд¿ØÖÆÆ÷Âß¼­´úÂë £¬ÒÔʵÏÖÓªÒµÂß¼­¡£

ÔÚ·Óɽç˵ÖÐÖ¸¶¨¿ØÖÆÆ÷ÒªÁìÀ´»á¼û¿ØÖÆÆ÷¡£

ÔÚä¯ÀÀÆ÷ÖвâÊÔ¿ØÖÆÆ÷ÊÇ·ñÕý³£ÊÂÇé¡£

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

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

Ïà¹ØÐÂÎÅ

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

18523999891

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

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

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