尊龙凯时人生就是搏

laravel¿ò¼ÜÔõôÌìÉú

laravel¿ò¼ÜÔõôÌìÉú

Ëæ×ÅWebÓ¦ÓóÌÐòµÄÐèÇóÒ»Ö±ÔöÌí£¬Ê¹Óÿò¼ÜÀ´½¨ÉèÈí¼þÒ²±äµÃÔ½À´Ô½Ê¢ÐС£Laravel¿ò¼ÜÊÇÒ»ÖÖÊ¢ÐеÄWebÓ¦ÓóÌÐò¿ò¼Ü£¬ËüÌṩÁËÐí¶àÏÖ´ú¿ª·¢¹¤¾ßºÍÊÖÒÕ£¬¿É×ÊÖúÄú¿ìËÙ¹¹½¨ÖØ´óµÄWebÓ¦ÓóÌÐò¡£

±¾ÎĽ«ÏòÄúÏÈÈÝLaravel¿ò¼ÜµÄÌìÉúÀú³Ì¡£ÎÒÃǽ«´ÓLaravelµÄ×°Öõ½ÌìÉú³õʼӦÓóÌÐò£¬ÔÙÏÈÈÝÔõÑù½¨ÉèÊý¾Ý¿âǨáãÒÔ¼°»ù±¾µÄ¿ØÖÆÆ÷ºÍÊÓͼÎļþ¡£

Ò»¡¢×°ÖÃLaravel

ҪװÖÃLaravel£¬ÄúÐèÒªÔÚÅÌËã»úÉÏ×°ÖÃPHPºÍComposer¡£ÔÚ´ËÖ®ºó£¬¿ÉÒÔʹÓÃComposerÀ´×°ÖÃLaravel¡£

ʹÓÃComposer×°ÖÃLaravel

·­¿ªÖնˣ¨»òÏÂÁîÌáÐÑ·û£©£¬²¢µ¼º½µ½ÄúҪװÖÃLaravelµÄĿ¼¡£ÔÚ¸ÃĿ¼Ï£¬¼üÈëÒÔÏÂÏÂÁ

composer create-project laravel/laravel my-projec

Õâ»áÏÂÔØLaravel¿ò¼Ü²¢½¨ÉèÒ»¸öÃûΪmy-projectµÄĿ¼¡£¸ÃĿ¼°üÀ¨LaravelµÄËùÓÐÎļþºÍĿ¼£¬ÒÔ¼°°üÀ¨ÓÃÓÚ¹¹½¨Ó¦ÓóÌÐòËùÐèµÄÆäËûÒÀÀµÏî¡£

¶þ¡¢ÌìÉú³õʼӦÓóÌÐò

ÀÖ³É×°ÖÃLaravelºó£¬Äú¿ÉÒÔʹÓÃLaravelµÄÏÂÁîÐй¤¾ßÌìÉúLaravelÓ¦ÓóÌÐòµÄ³õʼ½á¹¹¡£

ÌìÉú³õʼӦÓóÌÐò

·­¿ªÖնˣ¬²¢µ¼º½µ½ÒÑ×°ÖÃLaravelµÄĿ¼¡£ÔÚÏÂÁîÐÐÖÐÊäÈëÒÔÏÂÏÂÁ

php artisan make:auth

Õ⽫½¨ÉèÉí·ÝÑéÖ¤½çÃæ²¢ÌìÉú¿ØÖÆÆ÷¡¢ÊÓͼºÍ·ÓɵȱØÐèµÄÎļþºÍĿ¼¡£

ÔËÐÐÓ¦ÓóÌÐò

ÔËÐÐLaravelÓ¦ÓóÌÐò£¬¿ÉÒÔʹÓÃÒÔÏÂÏÂÁ

php artisan serve

´ËÏÂÁÆô¶¯¿ª·¢WebЧÀÍÆ÷£¬¿ÉÒÔÔÚä¯ÀÀÆ÷Öлá¼ûÓ¦ÓóÌÐò¡£

Èý¡¢½¨ÉèÊý¾Ý¿âǨáã

ÔÚLaravelÖУ¬Äú¿ÉÒÔʹÓÃǨáãÀ´ÖÎÀíÊý¾Ý¿âµÄÊý¾Ý½á¹¹¡£Êý¾Ý¿âǨáãÊÇÒ»ÖÖ¿ÉÖظ´µÄÒªÁ죬¿ÉÒÔʹÄúÇáËÉÌí¼Ó¡¢Ð޸ĺ͵õÏúÊý¾Ý¿â±íµÄ½á¹¹¡£

½¨ÉèеÄǨáã

Ϊ½¨ÉèеÄÊý¾Ý¿âǨá㣬ÇëÔÚÖÕ¶ËÖÐÊäÈëÒÔÏÂÏÂÁ

php artisan make:migration create_posts_table

´ËÏÂÁÔÚLaravelÊý¾Ý¿âǨáãĿ¼ÖеÄmigrationsĿ¼Öн¨ÉèÒ»¸öÐÂÎļþ13λÃüÃû¼Æ»®µÄÎļþ¡£

ÐÞ¸ÄǨáã

·­¿ªÇ¨áãÎļþ²¢Ê¹ÓÃLaravelÌṩµÄSchemaÀà½ç˵Ҫ½¨ÉèµÄ¹¤¾ß¡£ÀýÈ磬ÒÔÏÂÊǽ¨ÉèÃûΪ”posts”µÄ±íµÄʾÀý£º

use IlluminateSupportFacadesSchema;

use IlluminateDatabaseSchemaBlueprint;

use IlluminateDatabaseMigrationsMigration;

class CreatePostsTable extends Migration

{

public function up()
{
    Schema::create('posts', function (Blueprint $table) {
        $table->increments('id');
        $table->string('title');
        $table->text('body');
        $table->timestamps();
    });
}

public function down()
{
    Schema::dropIfExists('posts');
}

µÇ¼ºó¸´ÖÆ

}

´ËǨá㽫ÔÚÊý¾Ý¿âÖн¨ÉèÒ»¸öÃûΪ”posts”µÄ±í£¬²¢°üÀ¨×ֶΔid”£¬”title”£¬”body”ÒÔ¼°Êý¾Ý¿âµÄĬÈÏʱ¼ä´Á×ֶΡ£

ÔËÐÐǨáã

ÒªÓ¦ÓÃÕâ¸öǨáã²¢½¨ÉèÏìÓ¦µÄ±í£¬ÇëÔÚÖÕ¶ËÖÐÔËÐÐÒÔÏÂÏÂÁ

php artisan migrate

Õ⽫½¨ÉèÖ¸¶¨µÄ±í¡£

ËÄ¡¢½¨Éè»ù±¾¿ØÖÆÆ÷ºÍÊÓͼ

½¨Éè¿ØÖÆÆ÷

ʹÓÃÒÔÏÂÏÂÁîÔÚÖÕ¶ËÖн¨ÉèÒ»¸öеĿØÖÆÆ÷£º

php artisan make:controller PostController

Õ⽫½¨ÉèÒ»¸öеÄPostController.phpÎļþ£¬¸ÃÎļþλÓÚapp/Http/ControllersĿ¼ÖС£

¿ØÖÆÆ÷±àд

ÔÚеÄPostController.phpÎļþÖУ¬½«ÒÔÏÂÄÚÈÝÌí¼Óµ½Îļþ¿ªÍ·£º

namespace AppHttpControllers;

use IlluminateHttpRequest;

class PostController extends Controller

{

//

µÇ¼ºó¸´ÖÆ

}

´Ë´úÂëµ¼ÈëLaravelµÄ¿ØÖÆÆ÷À࣬²¢½¨ÉèÒ»¸öÃûΪPostControllerµÄ¿ØÖÆÆ÷Àà¡£

Ìí¼ÓÒÔÏÂÒªÁìÒÔ´¦Àí¿ØÖÆÆ÷µÄ²Ù×÷£º

public function index()

{

return view('posts.index');

µÇ¼ºó¸´ÖÆ

}

´ËÒªÁ콫·µ»ØÒ»¸öÃûΪ”index”µÄÊÓͼ£¬²¢ÓÉÊÓͼÎļþ¿ØÖÆ¡£

½¨ÉèÊÓͼ

ʹÓÃÒÔÏÂÏÂÁîÔÚÖÕ¶ËÖн¨ÉèÒ»¸öеÄÊÓͼ£º

php artisan make:view posts.index

Õâ»á½¨ÉèÒ»¸öÃûΪ”index.blade.php”µÄÊÓͼÎļþ¡£¸ÃÎļþλÓÚresources/views/postsĿ¼ÖС£

ÊÓͼ±àд

ÔÚн¨ÉèµÄ”index.blade.php”ÎļþÖУ¬Ìí¼ÓÒÔÏÂÄÚÈÝ£º

@extends(‘layouts.app’)

@section(‘content’)

<h1>All Posts</h1>

µÇ¼ºó¸´ÖÆ

@endsection

´ËÊÓͼ»ùÓÚÃû³ÆΪ”layouts.app”µÄ½á¹¹£¬²¢°üÀ¨Ò»¸öÎÊÌâΪ”All Posts”µÄHTMLÔªËØ¡£

Îå¡¢×ܽá

ÔÚ±¾ÎÄÖУ¬ÎÒÃÇÏÈÈÝÁËÔõÑù×°ÖÃLaravel¿ò¼ÜºÍÌìÉú³õʼӦÓóÌÐò£¬ÒÔ¼°ÔõÑùʹÓÃLaravelµÄÊý¾Ý¿âǨáãºÍ¿ØÖÆÆ÷/ÊÓͼÎļþ½¨ÉèWebÓ¦ÓóÌÐòµÄ»ù´¡½á¹¹¡£

ʹÓÃLaravelÄܹ»¸ü¿ì¡¢¸ü±ãµ±µÄ½¨ÉèWebÓ¦ÓóÌÐò£¬²¢ÇÒÌṩÁËÖÚ¶àÏÖ´ú¿ª·¢¹¤¾ßºÍÊÖÒÕ£¬È繤¾ß¹ØϵӳÉ䣨ORM£©¡¢Ä£°åÒýÇæ¡¢RESTful APIµÈ¡£LaravelÒѳÉΪÆÕ±éʹÓõÄWebÓ¦ÓóÌÐò¿ò¼Ü£¬ÎÞÂÛÄúÊÇÐÂÊÖÕÕ¾ÉÂÄÀú¸»ºñµÄ¿ª·¢Ö°Ô±£¬Ëü¶¼ÊÇÒ»¸öÖµµÃѧϰºÍʹÓõĿò¼Ü¡£

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

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

Ïà¹ØÐÂÎÅ

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

18523999891

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

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

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