laravel·ÓÉÍÉ»¯
laravelÊÇÒ»¸öÊ¢ÐеÄphp¿ò¼Ü£¬ËüÌṩÁËÒ»ÖÖ¼òÆÓ¶øÇ¿Ê¢µÄ·ÓÉ»úÖÆ£¬Ê¹¿ª·¢Ö°Ô±Äܹ»ÔÚÓ¦ÓóÌÐòÖнç˵url·ÓɺÍÇëÇó´¦Öóͷ£¡£²»¹ý£¬ÓÐʱ¼ä¿ª·¢ÕßÓöµ½ÁËһЩ·ÓÉÍÉ»¯µÄÎÊÌ⣬ÏÂÃæ¾ÍÏÈÈÝһϳ£¼ûµÄlaravel·ÓÉÍÉ»¯ÎÊÌâÒÔ¼°½â¾öÒªÁì¡£
·Óɽç˵¹ýʧ
ÔÚLaravelÖУ¬Í¨³£Ê¹Ó÷Óɽç˵À´°ó¶¨ÇëÇóÓë¿ØÖÆÆ÷ÒªÁìµÄÓ³Éä¹Øϵ¡£ÈôÊÇ·Óɽç˵Óйýʧ£¬¾Í»áµ¼Ö·Óɲ»Æð×÷Óá£
ÀýÈ磬ÏÂÃæÕâ¸öÀý×ÓÑÝʾÁËÒ»¸ö׼ȷµÄ·Óɽç˵£º
Route::get('/user/{id}', 'UserController@getUser');
µÇ¼ºó¸´ÖÆ
Õâ¸ö·Óɽç˵½«ÇëÇóµÄURLÖеıäÁ¿{id}ת´ï¸ø¿ØÖÆÆ÷µÄgetUserÒªÁì¡£ÈôÊÇÓû§»á¼ûÈçÏÂURL£¬Ôò»á׼ȷµØŲÓÃgetUserÒªÁ죺
http://your-app-url/user/123
µÇ¼ºó¸´ÖÆ
¿ÉÊÇ£¬ÈôÊÇ·Óɽç˵¹ýʧ£¬ºÃ±ÈȱÉÙ¡®/¡¯£¬Ôò¿ÉÄܻῴµ½404 Not Found»òÕßMethodNotAllowedHttpExceptionµÈ¹ýʧ¡£
½â¾öÒªÁ죺¼ì²é·Óɽç˵£¬È·±£ËüÃÇÇкÏLaravel·Óɽç˵ÃûÌã¬Í¬Ê±È·±£¶ÔÓ¦µÄ¿ØÖÆÆ÷ºÍÒªÁì±£´æ¡£
»º´æÎÊÌâ
LaravelÌṩһ¸ö»º´æ»úÖÆÀ´Ìá¸ß·ÓɵÄÐÔÄÜ£¬¿ÉÒÔͨ¹ýArtisanÏÂÁîÐй¤¾ß½«Â·ÓÉ»º´æµ½ÎļþÖС£
ÈôÊÇ»º´æÎļþ±»Ë𻵻òÕßûÓÐÌìÉú£¬¾Í¿ÉÄ᷺ܻÆð·Óɲ»Æð×÷ÓõÄÎÊÌâ¡£
½â¾öÒªÁ죺ɨ³ý·ÓÉ»º´æ£¬¿ÉÒÔʹÓÃÏÂÃæµÄArtisanÏÂÁ
php artisan route:clear
µÇ¼ºó¸´ÖÆ
È»ºóÖØÐÂÌìÉú·ÓÉ»º´æ£º
php artisan route:cache
µÇ¼ºó¸´ÖÆ
ÖÐÐļþÎÊÌâ
LaravelÖÐÐļþÊÇ·ÓÉ´¦Öóͷ£Á÷³ÌÖеÄÒ»²¿·Ö£¬¿ÉÒÔÔÚÇëÇóµÖ´ï¿ØÖÆÆ÷֮ǰ»òÖ®ºóÖ´ÐÐijЩ²Ù×÷¡£
ÈôÊÇÖÐÐļþµÄÉèÖÃÍÉ»¯£¬¿ÉÄܻᵼÖ·Óɲ»Æð×÷Óá£
½â¾öÒªÁ죺¼ì²éÖÐÐļþµÄÉèÖã¬È·±£ËüÃÇÔÚ·Óɽç˵ÖÐ׼ȷʹÓá£
Îļþ·¾¶ÎÊÌâ
µ±ÄúÔÚLaravelÓ¦ÓóÌÐòÖÐʹÓÃÖض¨Ïòʱ£¬ÈôÊÇÎļþ·¾¶²»×¼È·£¬Â·ÓÉÒ²»áʧ°Ü¡£Í¨³££¬ÕâÖÖÇéÐÎϽ«ÏÔʾ404¹ýʧ¡£
½â¾öÒªÁ죺¼ì²éÎļþ·¾¶£¬È·±£Îļþ±£´æ²¢ÇÒÏà¶Ô·¾¶»ò¾ø¶Ô·¾¶×¼È·¡£
csrf_tokenÎÊÌâ
LaravelÌṩµÄcsrf_tokenÊÇÒ»ÖÖÇå¾²»úÖÆ£¬ÓÃÓÚ±ÜÃâ¿çÕ¾µãÇëÇóαÔì¹¥»÷¡£ÈôÊÇδÉèÖÃcsrf_token»òÕßcsrf_token²»×¼È·£¬Ôò¿ÉÄܻᵼÖ·Óɲ»Æð×÷Óá£
½â¾öÒªÁ죺ȷ±£ÔÚʹÓÃPOST£¬PUT»òDELETEÇëÇóʱ£¬ÎªÃ¿¸öÇëÇóÉèÖÃ׼ȷµÄcsrf_tokenÖµ¡£¿ÉÒÔͨ¹ýÔÚHTML±íµ¥ÖаüÀ¨csrf_tokenÒþ²Ø×Ö¶ÎÀ´×Ô¶¯ÉèÖÃcsrf_tokenÖµ¡£
×ܽá
ÒÔÉÏÊÇһЩ³£¼ûµÄlaravel·ÓÉÍÉ»¯ÎÊÌâÒÔ¼°½â¾öÒªÁì¡£ÔÚ¿ª·¢Àú³ÌÖУ¬Óöµ½Â·ÓÉÎÊÌâʱӦ¸Ã×ÐϸÅŲ飬Éó²éÈÕÖ¾£¬È·±£ÉèÖÃ׼ȷ£¬²Å»ª°ü¹ÜÓ¦ÓóÌÐòµÄÕý³£ÔËÐС£
ÒÔÉϾÍÊÇlaravel·ÓÉÍÉ»¯µÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡