×ðÁú¿­Ê±¹ÙÍøµÇ¼

laravel ÔõôÓÃ

laravel ÊÇÒ»ÖÖÊ¢ÐÐµÄ php web Ó¦ÓóÌÐò¿ò¼Ü£¬ËüÌṩÁËÐí¶àÓÐÓõĹ¦Ð§£¬×ÊÖú web ¿ª·¢Ö°Ô±¿ìËÙ¹¹½¨ºÍ°²ÅŸßÖÊÁ¿µÄ web Ó¦ÓóÌÐò¡£ÒÔÏÂÊÇһЩʹÓà laravel µÄ»ù±¾°ì·¨£º

×°ÖÃ Laravel

Ê×ÏÈ£¬ÄúÐèÒªÔÚÍâµØÅÌËã»úÉÏ×°Öà Laravel¡£Äú¿ÉÒÔʹÓà Composer ÔÚ Windows¡¢Mac »ò Linux ÉÏ×°Öà Laravel¡£Composer ÊÇÒ»ÖÖ PHP ÒÀÀµÐÔÖÎÀíÆ÷£¬ËüÄܹ»×Ô¶¯ÏÂÔغÍ×°Öà Laravel ¼°ÆäÒÀÀµÏî¡£

ʹÓà Composer ×°Öà Laravel ºÜÊÇÈÝÒס£Ö»Ðè·­¿ªÖն˻òÏÂÁîÌáÐÑ·û£¬È»ºóÊäÈëÒÔÏÂÏÂÁ

composer global require laravel/installer

µÇ¼ºó¸´ÖÆ

´ËÏÂÁȫ¾Ö×°Öà Laravel ×°ÖóÌÐò¡£×°ÖÃÍê³Éºó£¬Äú¿ÉÒÔʹÓÃÒÔÏÂÏÂÁÉè Laravel ÏîÄ¿µÄÐÂʵÀý£º

laravel new myproject

µÇ¼ºó¸´ÖÆ

ÉèÖÃÊý¾Ý¿â

Laravel »¹ÐèÒªÊý¾Ý¿â²Å»ªÔËÐС£Ä¬ÈÏÇéÐÎÏ£¬Laravel ʹÓà MySQL Êý¾Ý¿â£¬µ«»¹Ö§³ÖÆäËûÊý¾Ý¿â£¬Èç PostgreSQL¡¢SQLite ºÍ SQL Server¡£ÄúÐèÒªÔÚ .env ÎļþÖÐÉèÖÃÊý¾Ý¿âÅþÁ¬ÐÅÏ¢¡£ÀýÈ磬ÈôÊÇÄúʹÓà MySQL Êý¾Ý¿â£¬Ôò .env ÎļþÈçÏÂËùʾ£º

DB_DATABASE=your_database_name
DB_USERNAME=your_database_username
DB_PASSWORD=your_database_password

µÇ¼ºó¸´ÖÆ

È·±£½«ÕâЩֵÌ滻ΪÄúµÄÏÖʵÊý¾Ý¿âÃû³Æ¡¢Óû§ÃûºÍÃÜÂë¡£

ʹÓà Artisan ÏÂÁîÐнçÃæ

Laravel ¸½´øÒ»¸öÏÂÁîÐнçÃ湤¾ß£¬³ÆΪ Artisan£¬Ëü¿ÉÒÔ×ÊÖúÄúÖ´ÐÐÖÖÖÖÓÐÓõÄʹÃü£¬Èç´úÂëÌìÉú¡¢Êý¾Ý¿âǨáã¡¢¿ØÖÆ̨ÏÂÁîºÍ²âÊÔ¡£ÒÔÏÂÊÇһЩ³£ÓÃµÄ Artisan ÏÂÁ

ÌìÉú¿ØÖÆÆ÷£ºphp artisan make:controller MyController

ÌìÉúÄ£×Ó£ºphp artisan make:model MyModel

ÌìÉúǨá㣺php artisan make:migration create_users_table

ÔËÐÐǨá㣺php artisan migrate

ÌìÉú seeder£ºphp artisan make:seeder UserSeeder

ÔËÐÐ seeder£ºphp artisan db:seed

½ç˵·ÓÉ

Laravel ʹÓ÷ÓÉÀ´È·¶¨ÔõÑùÏìÓ¦À´×Ô Web ä¯ÀÀÆ÷µÄÇëÇó¡£ÔÚ Laravel ÖУ¬Â·ÓÉÓÃÓÚ½« URL ºÍÇëÇóÀàÐÍÓ³Éäµ½Ìض¨µÄ¿ØÖÆÆ÷ÒªÁì¡£Òª½ç˵·ÓÉ£¬Äú¿ÉÒÔ·­¿ª routes/web.php Îļþ£¬²¢Ìí¼ÓÀàËÆÓÚÒÔÏÂÄÚÈݵĴúÂ룺

Route::get('/', function () {
    return view('welcome');
});

µÇ¼ºó¸´ÖÆ

´Ë´úÂëÌåÏÖ½«¸ù URL Ó³Éäµ½ÃûΪ welcome µÄÊÓͼ¡£Äú»¹¿ÉÒÔʹÓÃÆäËûÇëÇóÀàÐÍ£¬ÀýÈç POST¡¢PUT¡¢PATCH ºÍ DELETE¡£ÀýÈ磬ÒÔÏ´úÂ뽫 POST ÇëÇóÓ³Éäµ½ÃûΪ UserController µÄ¿ØÖÆÆ÷µÄ store ÒªÁ죺

Route::post('/users', 'UserController@store');

µÇ¼ºó¸´ÖÆ

½¨Éè¿ØÖÆÆ÷

¿ØÖÆÆ÷ÓÃÓÚ´¦Àí Web Ó¦ÓóÌÐòµÄÇëÇó£¬Ö´ÐÐÓªÒµÂß¼­²¢ÌìÉúÏìÓ¦¡£Äú¿ÉÒÔʹÓà Artisan ÏÂÁîÐй¤¾ß½¨ÉèÒ»¸ö¿ØÖÆÆ÷¡£ÀýÈ磬ÒÔÏÂÏÂÁî»áÌìÉúÒ»¸öÃûΪ UserController µÄ¿ØÖÆÆ÷£º

php artisan make:controller UserController

µÇ¼ºó¸´ÖÆ

´ËÏÂÁÔÚ app/Http/Controllers Ŀ¼ÖÐÌìÉú UserController.php Îļþ¡£

½¨ÉèÊÓͼ

ÊÓͼÊÇ Laravel Ó¦ÓóÌÐòÖд¦Àí×îÖÕ HTML Êä³öµÄ×é¼þ¡£ÔÚ Laravel ÖУ¬ÊÓͼÊÇʹÓà Blade Ä£°åÒýÇ潨ÉèµÄ¡£ÊÓͼ¿ÉÒÔ°üÀ¨¾²Ì¬ HTML¡¢PHP ´úÂëºÍ Laravel Ä£°åÓï·¨¡£Äú¿ÉÒÔʹÓÃÒÔÏ Artisan ÏÂÁÉèеÄÊÓͼ£º

php artisan make:view myview

µÇ¼ºó¸´ÖÆ

´ËÏÂÁÔÚ resources/views Ŀ¼Öн¨ÉèÒ»¸öÃûΪ myview.blade.php µÄÐÂÎļþ¡£Äú¿ÉÒÔÔÚÆäÖÐÌí¼Ó HTML¡¢PHP ´úÂëºÍÄ£°å±ê¼Ç£¨ÀýÈç {{ $variable }} ºÍ @foreach£©ÒÔÌìÉúÊÓͼ¡£

ÔËÐÐ Laravel Ó¦ÓóÌÐò

µ±Äú×¼±¸ºÃÔËÐÐ Laravel Ó¦ÓóÌÐòʱ£¬¿ÉÒÔÔÚÖն˻òÏÂÁîÌáÐÑ·ûÏÂÊäÈëÒÔÏÂÏÂÁ

php artisan serve

µÇ¼ºó¸´ÖÆ

´ËÏÂÁÔÚµ±ÌïÖ÷»úÉÏÆô¶¯ PHP ÄÚÖà Web ЧÀÍÆ÷£¬²¢½«ÄúµÄ Laravel Ó¦ÓóÌÐòÔËÐÐÔÚ http://localhost:8000 ÉÏ¡£

×ܽá

Laravel ÊÇÒ»ÖÖ¼òÆÓÒ×ÓÃµÄ PHP Web Ó¦ÓóÌÐò¿ò¼Ü£¬ËüÌṩÁËÐí¶àÓÐÓõĹ¦Ð§£¬ÀýÈç·ÓÉ¡¢¿ØÖÆÆ÷¡¢ÊÓͼºÍ Artisan ÏÂÁîÐнçÃ档ͨ¹ýʹÓà Laravel£¬Äú¿ÉÒÔ´ó´ó¼ÓËٺͼò»¯ Web Ó¦ÓóÌÐòµÄ¿ª·¢ºÍ°²ÅÅ¡£

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

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

Ïà¹ØÐÂÎÅ

ÁªÏµ×ðÁú¿­Ê±¹ÙÍøµÇ¼

18523999891

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

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

QR code
ÍøÕ¾µØͼ