尊龙凯时人生就是博

ÔõÑùʹÓÃLaravel¿ò¼ÜÀ´¹¹½¨WebÓ¦ÓóÌÐò

laravelÊÇÒ»¸ö¹¦Ð§Ç¿Ê¢µÄphp¿ò¼Ü £¬ËüÌṩÁËһϵÁеŤ¾ßºÍ×é¼þ £¬ÉÁ¿ª·¢Õß¿ÉÒÔ¿ìËÙ¡¢¸ßЧµØ¹¹½¨webÓ¦ÓóÌÐò¡£ÔÚ¿ª·¢webÓ¦ÓóÌÐòµÄÀú³ÌÖÐ £¬ÄúÐèÒªÕÆÎÕlaravel¿ò¼ÜµÄ½¹µã¿´·¨ºÍ֪ʶ £¬Í¬Ê±Ê¹ÓÃһЩ³£ÓõŤ¾ßºÍÊÖÒÕ¡£±¾ÎĽ«ÏÈÈÝÔõÑùʹÓÃlaravel¿ò¼ÜÀ´¹¹½¨webÓ¦ÓóÌÐò¡£

×°ÖÃLaravel

Ê×ÏÈ £¬ÄúÐèÒªÔÚÍâµØÅÌËã»úÉÏ×°ÖÃLaravel¡£Äú¿ÉÒÔʹÓÃComposerÀ´×°ÖÃLaravel¡£ComposerÊÇPHPµÄÒ»¸öÒÀÀµÖÎÀíÆ÷ £¬Ëü¿ÉÒÔ×°ÖᢸüкÍÖÎÀíPHP°ü¡£ÏÂÃæÊÇ×°ÖÃLaravelµÄ°ì·¨£º

·­¿ªÖն˻òÏÂÁîÐй¤¾ß

ÔËÐÐÒÔÏÂÏÂÁcomposer global require laravel/installer

ÔËÐÐÒÔÏÂÏÂÁlaravel new your_project_name

½øÈëÄúµÄÏîĿĿ¼£ºcd your_project_name

ÔËÐÐLaravel¿ª·¢Ð§ÀÍÆ÷£ºphp artisan serve

½¨Éè·ÓÉ

ÔÚLaravelÖÐ £¬Â·ÓÉÓÃÓÚ½ç˵ÇëÇóURIºÍHTTPÇëÇóÐж¯Ö®¼äµÄÓ³Éä¡£Äú¿ÉÒÔͨ¹ý½¨Éè·ÓÉÀ´´¦ÀíHTTPÇëÇó²¢·µ»ØÏìÓ¦¡£LaravelÖеÄ·ÓÉϵͳºÜÊǼòÆÓ £¬ÄúÖ»ÐèÒª½ç˵ÇëÇóURIºÍHTTPÇëÇóÐж¯¼´¿É¡£ÀýÈç £¬ÒÔÏ·ÓÉÉùÃ÷½«´¦ÀíGETÇëÇó²¢·µ»ØHello World£º

Route::get(‘/’, function () {

return 'Hello World';

µÇ¼ºó¸´ÖÆ

});

½¨Éè¿ØÖÆÆ÷

ÔÚLaravelÖÐ £¬¿ØÖÆÆ÷ÓÃÓÚ´¦ÀíHTTPÇëÇó²¢ÌìÉúÏìÓ¦¡£Äú¿ÉÒÔͨ¹ý½¨Éè¿ØÖÆÆ÷À´½«ÇëÇóÁ÷³ÌÊèɢΪ²î±ðµÄ²Ù×÷¡£ÒÔÏ´úÂëÑÝʾÁËÔõÑù½¨ÉèÒ»¸öÃûΪUserControllerµÄ¿ØÖÆÆ÷£º

php artisan make:controller UserController

È»ºó £¬Äú¿ÉÒÔʹÓÃÒÔÏÂÒªÁìÌí¼Ó²Ù×÷£º

public function index()

{

// Some logic here

µÇ¼ºó¸´ÖÆ µÇ¼ºó¸´ÖÆ

}

public function show($id)

{

// Some logic here

µÇ¼ºó¸´ÖÆ µÇ¼ºó¸´ÖÆ

}

½¨ÉèÊÓͼ

ÔÚLaravelÖÐ £¬¿ÉÒÔʹÓÃÊÓͼÀ´ÌìÉúWeb½çÃæ»òäÖȾHTML¡£ÊÓͼÊÇÒ»¸ö¼òÆÓµÄHTMLÎļþ £¬ÆäÖаüÀ¨¶¯Ì¬ÌìÉúµÄÊý¾Ý¡£Äú¿ÉÒÔʹÓÃBladeÄ£°åÒýÇæÀ´´¦ÀíÊÓͼ¡£ÒÔÏÂÊÇÔõÑù½¨ÉèÒ»¸öÊÓͼµÄ´úÂ룺

php artisan make:view welcome

½ÓÏÂÀ´ £¬Äú¿ÉÒÔÔÚÒÔϵصãÕÒµ½Äú½¨ÉèµÄÊÓͼ£ºresources/views/welcome.blade.php¡£

ÓëÊý¾Ý¿â½»»¥

ÔÚLaravelÖÐ £¬Äú¿ÉÒÔʹÓÃEloquent ORMÓëÊý¾Ý¿â½»»¥¡£Eloquent ORMÊÇÒ»¸ö¼òÆÓµÄActive RecordʵÏÖ £¬Ëü¿ÉÒÔÈÃÄúºÜÊÇÀû±ãµØ´ÓÊý¾Ý¿âÖмìË÷¡¢Ìí¼Ó¡¢¸üкÍɾ³ý¼Í¼¡£ÒÔÏ´úÂëÑÝʾÁËÔõÑùʹÓÃEloquent ORM´Óusers±íÖмìË÷ËùÓмͼ£º

$users = User::all();

½¨ÉèǨáã

ÔÚLaravelÖÐ £¬Äú¿ÉÒÔʹÓÃǨáãÀ´ÖÎÀíÊý¾Ý¿â¼Ü¹¹¡£Ç¨áãÊÇÒ»ÖÖ»úÖÆ £¬¿ÉÒÔÈÃÄúÇáËɵظú×ÙºÍÐÞ¸ÄÊý¾Ý¿â½á¹¹¡£Äú¿ÉÒÔʹÓÃÒÔÏÂÏÂÁÉèÒ»¸öÃûΪusersµÄǨáãÎļþ£º

php artisan make:migration create_users_table –create=users

¸ÃÏÂÁÌìÉúÒ»¸öǨáãÎļþ £¬Äú¿ÉÒԱ༭¸ÃÎļþÒÔ½ç˵ҪִÐеIJÙ×÷ £¬ÀýÈ罨Éè»òɾ³ý±í¡£ÒÔÏÂÊÇÈç×÷Éõusers±í½¨ÉèÒ»¸öǨáãµÄ´úÂ룺

public function up()

{

Schema::create('users', function (Blueprint $table) {
    $table->id();
    $table->string('name');
    $table->string('email')->unique();
    $table->timestamp('email_verified_at')->nullable();
    $table->string('password');
    $table->rememberToken();
    $table->timestamps();
});

µÇ¼ºó¸´ÖÆ

}

ʹÓÃÖÐÐļþ

ÔÚLaravelÖÐ £¬Äú¿ÉÒÔʹÓÃÖÐÐļþÀ´´¦ÀíHTTPÇëÇó¡£ÖÐÐļþÊÇÒ»ÖÖ»úÖÆ £¬¿ÉÒÔÈÃÄúÔÚÇëÇóµÖ´ïÄúµÄÓ¦ÓóÌÐò֮ǰ»òÖ®ºóÖ´ÐвÙ×÷¡£ÀýÈç £¬Äú¿ÉÒÔ½¨ÉèÒ»ÆäÖÐÐļþÀ´ÑéÖ¤Óû§ÊÇ·ñÒѵǼ £¬ÈôÊÇûÓеǼ £¬ÔòÐèÒª½«Óû§Öض¨Ïòµ½µÇ¼ҳÃæ¡£ÒÔÏ´úÂëÊÇÔõÑù½¨É貢ʹÓÃÒ»¸öÃûΪAuthenticateµÄÖÐÐļþµÄʾÀý£º

php artisan make:middleware Authenticate

public function handle($request, Closure $next)

{

if (! $request->user()) {
    return redirect('/login');
}

return $next($request);

µÇ¼ºó¸´ÖÆ

}

¼¯³ÉµÚÈý·½Ð§ÀÍ

ÔÚLaravelÖÐ £¬Äú¿ÉÒÔÇáËɵؼ¯³ÉÖÖÖÖµÚÈý·½Ð§ÀÍ £¬ÀýÈçÖ§¸¶Íø¹Ø¡¢ÓʼþЧÀÍ¡¢ÍÆËÍ֪ͨЧÀ͵È¡£Äú¿ÉÒÔʹÓÃLaravelµÄ¹Ù·½°ü»ò¿ª·¢µÄÀ©Õ¹À´¿ìËÙÍê³É´ËʹÃü¡£ÀýÈç £¬ÒÔÏ´úÂëÑÝʾÁËÔõÑùʹÓÃLaravelµÄ¹Ù·½°ülaravel/cashierÀ´¼¯³ÉStripeÖ§¸¶Íø¹Ø£º

composer require laravel/cashier

»º´æÕ½ÂÔ

ÔÚLaravelÖÐ £¬Äú¿ÉÒÔʹÓûº´æÀ´Ìá¸ßWebÓ¦ÓóÌÐòµÄÐÔÄÜ¡£LaravelÌṩÁËÐí¶à»º´æÇý¶¯³ÌÐò £¬ÀýÈçRedis¡¢MemcachedµÈ¡£Äú¿ÉÒÔʹÓÃÒÔÏ´úÂëƬ¶ÏÀ´½ç˵»º´æÕ½ÂÔ£º

Cache::remember(‘users’, $minutes, function () {

return DB::table('users')->get();

µÇ¼ºó¸´ÖÆ

});

ʹÓÃÐÐÁÐ

ÔÚLaravelÖÐ £¬Äú¿ÉÒÔʹÓÃÐÐÁÐÀ´´¦ÀíºÄʱºÍÐèÒªÒì²½Ö´ÐеÄʹÃü¡£ÐÐÁÐÊÇÒ»ÖÖ»úÖÆ £¬¿ÉÒÔÈÃÄú½«Ê¹Ãü·ÅÈëÐÐÁÐÖÐ £¬²¢ÔÚ´¦Àíʱ¼ä½Ï³¤µÄʹÃüʱ²»ÛÕ±ÕÖ÷Ó¦ÓóÌÐòÏ̡߳£Äú¿ÉÒÔʹÓÃĬÈÏÐÐÁÐÇý¶¯³ÌÐò»ò½«Ê¹Ãü·¢ÍùRedis¡¢BeanstalkdµÈЧÀÍ¡£ÒÔÏÂÊÇÔõÑù½«Ê¹ÃüÍÆÈëÐÐÁеÄʾÀý´úÂ룺

dispatch(function () {

// Some long-running code here

µÇ¼ºó¸´ÖÆ

});

×ܽá

ÒÔÉÏÊÇʹÓÃLaravel¿ª·¢WebÓ¦ÓóÌÐòµÄ»ù±¾°ì·¨¡£ËäÈ» £¬LaravelÌṩÁ˸ü¶àµÄ¹¦Ð§ºÍ¹¤¾ß £¬ÈÃÄú¿ÉÒÔÔ½·¢¸ßЧ¡¢ÎÞаµØ¿ª·¢WebÓ¦ÓóÌÐò¡£ÕÆÎÕÕâЩ½¹µã¿´·¨ºÍÊÖÒÕ £¬Äú½«Äܹ»¹¹½¨³ö¸ßÖÊÁ¿¡¢¸ßÐÔÄܵÄWebÓ¦ÓóÌÐò¡£

ÒÔÉϾÍÊÇÔõÑùʹÓÃLaravel¿ò¼ÜÀ´¹¹½¨WebÓ¦ÓóÌÐòµÄÏêϸÄÚÈÝ £¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

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

Ïà¹ØÐÂÎÅ

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

18523999891

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

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

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