尊龙凯时人生就是搏

laravelÖÐÐļþÈÏÕæʲô

laravel ÊÇÒ»¿îÊ¢ÐÐµÄ php ¿ªÔ´¿ò¼Ü £¬Í¨³£ÓÃÓÚ¿ª·¢ web Ó¦ÓóÌÐò¡£ËüÌṩÁËһϵÁй¤¾ßºÍ¹¦Ð§ £¬¿ÉÒÔÇáËɵع¹½¨¸ßÖÊÁ¿¡¢¿ÉÀ©Õ¹µÄÓ¦ÓóÌÐò¡£ÆäÖÐ £¬ÖÐÐļþÊÇ laravel µÄÖ÷Òª×é³É²¿·Ö £¬ËüÔÚÓ¦ÓóÌÐòÖÐÊÎÑÝÁ˺ÜÖ÷ÒªµÄ½ÇÉ«¡£

±¾ÎĽ«ÏÈÈÝ Laravel ÖÐÐļþµÄ»ù±¾¿´·¨¡¢×÷Óü°×ÅʵÏÖÔ­Àí £¬ÒÔ×ÊÖú¶ÁÕ߸üºÃµØÃ÷È·ÖÐÐļþµÄ×÷ÓúÍÓ÷¨¡£

ʲôÊÇÖÐÐļþ£¿

ÖÐÐļþÊÇ Laravel ÖÐÒ»ÖÖ´¦Àí HTTP ÇëÇóºÍÏìÓ¦µÄ»úÖÆ £¬ËüÌṩÁËÒ»ÖÖÎÞаµÄ·½·¨À´´¦ÀíÓ¦ÓóÌÐòÖÐÐí¶à³£¼ûµÄʹÃü £¬ÈçÉí·ÝÑéÖ¤¡¢Êý¾Ý¹ýÂË¡¢»á»°ÖÎÀíµÈ¡£ÖÐÐļþͨ³£Î»ÓÚÇëÇó´¦ÀíÁ÷³ÌµÄÖÐÐÄλÖà £¬¿ÉÒÔ¶ÔÇëÇóºÍÏìÓ¦¾ÙÐйýÂ˺ÍÐ޸ġ£

ÔÚ Laravel ÖÐ £¬ÖÐÐļþ¿ÉÒÔ±»ÓÃÓÚÁ½ÖÖ³¡¾°£ºÈ«¾ÖÖÐÐļþºÍ·ÓÉÖÐÐļþ¡£È«¾ÖÖÐÐļþÊÇÔÚËùÓÐ HTTP ÇëÇó֮ǰ´¦ÀíµÄ £¬¶ø·ÓÉÖÐÐļþ½ö¶ÔÌض¨Â·ÓɵÄÇëÇó¾ÙÐд¦Àí¡£ÖÐÐļþ¿ÉÒÔÊÇÒ»¸ö±Õ°üº¯Êý¡¢Ò»¸öÀà»òÒ»¸öʵÏÖÁË handle ÒªÁìµÄÀàµÄʵÀý¡£

ÖÐÐļþµÄ×÷ÓÃ

ÊÚȨºÍÈÏÖ¤

ÖÐÐļþ¿ÉÒÔÓÃÀ´ÑéÖ¤Óû§µÄÉí·Ý¡¢¼ì²éÓû§ÊÇ·ñÓÐȨ»á¼ûijЩ×ÊÔ´»òÕß±ÜÃâÓû§¾ÙÐв»·¨²Ù×÷¡£ºÃ±È £¬ÔÚÓû§ÊµÑé»á¼ûÖÎÀíºǫ́»òÕß²éÕÒÃô¸ÐÊý¾Ýʱ £¬¿ÉÒÔͨ¹ý±àдÏìÓ¦µÄÖÐÐļþÀ´¾ÙÐÐÉí·ÝÑéÖ¤¡£

¼Í¼ÈÕÖ¾

ÖÐÐļþ»¹¿ÉÒÔÓÃÀ´¼ÍÈÎÃü»§µÄÐÐΪºÍϵͳµÄÔËÐÐÇéÐΡ£ºÃ±È £¬¿ÉÒÔ±àдһÆäÖÐÐļþ £¬ÓÃÓÚ¼ÍÈÎÃü»§ÔÚÒ»¸öÌض¨Ò³ÃæµÄʱ¼ä £¬»òÕ߼ͼËùÓеÄÇëÇóºÍÏìÓ¦µÄʱ¼äºÍ״̬¡£Õâ¿ÉÒÔ×ÊÖú¿ª·¢Ö°Ô±¸üºÃµØÏàʶϵͳµÄÔËÐÐÇéÐÎ £¬²¢ÓÅ»¯Ó¦ÓóÌÐòµÄÐÔÄÜ¡£

ѹËõ»ººÍ´æ

ÖÐÐļþ»¹¿ÉÒÔÓÃÀ´Ñ¹Ëõ»ººÍ´æÏìÓ¦Êý¾Ý £¬ÒÔ¼ÓËÙÓû§»á¼ûËÙÂÊ¡£ºÃ±È £¬¿ÉÒÔʹÓÃÖÐÐļþѹËõËùÓеÄÏìÓ¦Êý¾Ý £¬ÒÔïÔÌ­´«Êäʱ¼äºÍ´ø¿íÕ¼Óà £¬»òÕßʹÓÃÖÐÐļþ»º´æһЩ¾²Ì¬Êý¾Ý £¬ÒÔïÔÌ­Êý¾Ý¿âÅÌÎÊ´ÎÊý¡£

Êý¾Ýת»»

ÖÐÐļþ¿ÉÒÔÓÃÀ´½«Öݪֲî±ðÃûÌõÄÊý¾Ý£¨Èç XML¡¢JSON¡¢CSV µÈ£©×ª»»ÎªÍ³Ò»µÄÊý¾ÝÃûÌá£ºÃ±È £¬¿ÉÒÔ±àдһÆäÖÐÐļþ £¬½«ËùÓеÄÏìÓ¦Êý¾Ý¶¼×ª»»Îª JSON ÃûÌà £¬ÒÔÀû±ã¿Í»§¶Ë¾ÙÐÐÆÊÎöºÍ´¦Àí¡£

ÖÐÐļþµÄʵÏÖ

ÔÚ Laravel ÖÐ £¬¿ÉÒÔͨ¹ý¼ÌÐø Illuminate\Http\Middleware\Middleware ÀàÀ´½¨Éè×Ô¼ºµÄÖÐÐļþ¡£ÖÐÐļþͨ³£°üÀ¨Ò»¸ö handle ÒªÁì £¬ÓÃÀ´´¦ÀíÇëÇóºÍÏìÓ¦¡£

ÏÂÃæÊÇÒ»¸ö¼òÆÓµÄÖÐÐļþʾÀý £¬ÓÃÓÚ¼ì²éÓû§ÊÇ·ñÓÐȨÏÞ»á¼ûijЩҳÃ棺

<?php   
namespace App\Http\Middleware;
  
use Closure;
  
class CheckUserPermission
{
    public function handle($request, Closure $next)
    {
        if (! $request->user()-&gt;hasPermissionTo('access-admin')) {
            return redirect('/login');
        }
  
        return $next($request);
    }
}

µÇ¼ºó¸´ÖÆ

ÔÚÉÏÃæµÄʾÀýÖÐ £¬handle ÒªÁìÎüÊÕÒ»¸ö $request ²ÎÊýºÍÒ»¸ö Closure ÀàÐ͵IJÎÊý $next £¬ÓÃÓÚ½«ÇëÇóת´ï¸øÏÂÒ»ÆäÖÐÐļþ»ò¿ØÖÆÆ÷¡£

½ÓÏÂÀ´ £¬¿ÉÒÔ½«ÖÐÐļþ×¢²áµ½Ó¦ÓóÌÐòÖС£¿ÉÒÔͨ¹ý app/Http/Kernel.php ÎļþµÄ $middleware ÊôÐÔÀ´Ìí¼ÓÈ«¾ÖÖÐÐļþ £¬Í¨¹ý $routeMiddleware ÊôÐÔÀ´Ìí¼Ó·ÓÉÖÐÐļþ¡£

ÏÂÃæÊÇÒ»¸ö¼òÆÓµÄʾÀý £¬×¢²áÉÏÃæµÄÖÐÐļþ£º

<?php namespace App\Http;
  
use Illuminate\Foundation\Http\Kernel as HttpKernel;
  
class Kernel extends HttpKernel
{
    protected $routeMiddleware = [
        'auth' => \App\Http\Middleware\Authenticate::class,
        'permission' =&gt; \App\Http\Middleware\CheckUserPermission::class,
    ];
}

µÇ¼ºó¸´ÖÆ

ÔÚÉÏÃæµÄʾÀýÖÐ £¬½«ÖÐÐļþ CheckUserPermission ×¢²áΪ·ÓÉÖÐÐļþ permission¡£

¿ÉÒÔͨ¹ýÔÚ·ÓÉÉùÃ÷ÖÐʹÓÃÖÐÐļþÃû³ÆÀ´½«ÆäÓ¦ÓÃÓÚ·ÓÉ¡£ÏÂÃæµÄʾÀýÑÝʾÁËÔõÑùʹÓÃÖÐÐļþ½«»á¼û /admin ·ÓɵÄÇëÇóÏÞÖÆΪÓÐÖÎÀíԱȨÏÞµÄÓû§£º

Route::get('/admin', function () {
    //
})-&gt;middleware('permission:access-admin');

µÇ¼ºó¸´ÖÆ

ÔÚÉÏÃæµÄʾÀýÖÐ £¬½«Â·ÓÉÖÐÐļþ permission Ó¦ÓÃÓÚ /admin ·ÓÉ £¬²¢×ª´ï access-admin ²ÎÊý £¬Ö¸Ê¾Óû§ÐèÒª¾ßÓÐ access-admin ȨÏ޲Żª»á¼û¸Ã·ÓÉ¡£

×ܽá

ÖÐÐļþÊÇ Laravel ³ÌÐòÖеÄÒ»¸öÇ¿Ê¢»úÖÆ £¬¿ÉÒÔÔÚÇëÇó´¦ÀíÀú³ÌÖоÙÐÐÊý¾Ý¹ýÂË¡¢Éí·ÝÑéÖ¤¡¢ÈÕÖ¾¼Í¼¡¢»º´æµÈÖݪֲÙ×÷¡£Ëüͨ¹ý¿ÉÀ©Õ¹µÄ·½·¨¶Ô´¦ÀíÁ÷³Ì¾ÙÐзâ×° £¬²¢ÌṩÁËÀû±ã¡¢ÎÞаµÄʹÓ÷½·¨¡£

±¾ÎÄÏÈÈÝÁË Laravel ÖÐÐļþµÄ»ù±¾¿´·¨¡¢Ó¦Óó¡¾°ºÍʵÏÖÒªÁì £¬Ï£Íû¶Ô¶ÁÕßÏàʶÖÐÐļþ±³ºóµÄÔ­ÀíºÍʹÓÃÒªÁìÓÐËù×ÊÖú¡£ÔÚÏÖʵ¿ª·¢ÖÐ £¬¿ÉÒÔƾ֤ÏêϸÐèÒª±àд×Ô¼ºµÄÖÐÐļþ £¬Ìá¸ßÓ¦ÓóÌÐòµÄ¿É¿¿ÐÔ¡¢¿ÉÀ©Õ¹ÐԺͿÉά»¤ÐÔ¡£

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

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

Ïà¹ØÐÂÎÅ

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

18523999891

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

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

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