laravel composerÔõôװÖÃ
laravelÊÇÒ»¿î»ùÓÚphpÓïÑÔ¿ª·¢µÄwebÓ¦Óÿò¼Ü£¬Ëü½ÓÄÉÁËÐí¶àÏȽøµÄÊÖÒÕºÍÉè¼ÆÍ·ÄÔ£¬¸øweb¿ª·¢´øÀ´ÁËÐí¶à±ãµ±¡£laravelÒÀÀµÓÚcomposer¾ÙÐаü¹ÜÀí£¬¿ÉÒÔÇáËɵØ×°Öú͸üÐÂÒÀÀµ¹Øϵ¡£±¾ÎĽ«ÏÈÈÝÔõÑùʹÓÃcomposer×°ÖÃlaravel¡£
×°ÖÃComposer
ÔÚʹÓÃComposer×°ÖÃLaravel֮ǰ£¬Ê×ÏÈÐèÒªÔÚ±¾»úÉÏ×°ÖÃComposer¡£×î¼òÆÓµÄ×°ÖÃÒªÁìÊÇʹÓÃϵͳ°ü¹ÜÀíÆ÷¾ÙÐÐ×°Öã¬ÀýÈçÔÚUbuntuÉÏʹÓÃÒÔÏÂÏÂÁ
sudo apt-get update sudo apt-get install composer
µÇ¼ºó¸´ÖÆ
×°ÖÃÍê³Éºó£¬¿ÉÒÔͨ¹ýÔËÐÐÒÔÏÂÏÂÁîÀ´ÑéÖ¤ÊÇ·ñ×°ÖÃÀֳɣº
composer --version
µÇ¼ºó¸´ÖÆ
½¨ÉèLaravelÏîÄ¿
ÔÚ×°ÖÃComposerÖ®ºó£¬¾Í¿ÉÒÔ×îÏȽ¨ÉèLaravelÏîÄ¿ÁË¡£¿ÉÒÔͨ¹ýÔËÐÐÒÔÏÂÏÂÁîÀ´½¨ÉèÏîÄ¿£º
composer create-project --prefer-dist laravel/laravel project-name
µÇ¼ºó¸´ÖÆ
ÆäÖУ¬project-nameΪÏîÄ¿µÄÃû³Æ£¬¿ÉÒÔƾ֤×Ô¼ºµÄÐèÇó¾ÙÐÐÐ޸ġ£ÏîÄ¿½¨ÉèÍê³Éºó£¬¿ÉÒÔÔËÐÐÒÔÏÂÏÂÁî½øÈëÏîĿĿ¼£º
cd project-name
µÇ¼ºó¸´ÖÆ
ÉèÖÃÊý¾Ý¿â
ÔÚ½¨ÉèLaravelÏîÄ¿Ö®ºó£¬ÐèÒªÉèÖÃÊý¾Ý¿â¡£ÔÚÏîÄ¿¸ùĿ¼Ï£¬¿ÉÒÔÕÒµ½.env.exampleÎļþ£¬½«Æ临ÖÆΪ.envÎļþ¡£È»ºó·¿ª.envÎļþ£¬ÕÒµ½ÒÔÏ´úÂ룺
DB_CONNECTION=mysql DB_HOST=127.0.0.1 DB_PORT=3306 DB_DATABASE=homestead DB_USERNAME=homestead DB_PASSWORD=secret
µÇ¼ºó¸´ÖÆ
½«ÆäÐÞ¸ÄΪ×Ô¼ºµÄÊý¾Ý¿âÐÅÏ¢¡£
ÌìÉúÓ¦ÓÃÃÜÔ¿
ÔÚÏîÄ¿ÖУ¬ÐèÒªÌìÉúÒ»¸öÓ¦ÓÃÃÜÔ¿¡£¿ÉÒÔͨ¹ýÒÔÏÂÏÂÁîÀ´ÌìÉú£º
php artisan key:generate
µÇ¼ºó¸´ÖÆ
ÔËÐÐLaravelЧÀÍ
ÔÚÍê³ÉÒÔÉÏ°ì·¨Ö®ºó£¬¿ÉÒÔͨ¹ýÒÔÏÂÏÂÁîÀ´ÔËÐÐLaravelЧÀÍ£º
php artisan serve
µÇ¼ºó¸´ÖÆ
ÔËÐÐÀֳɺ󣬿ÉÒÔÔÚä¯ÀÀÆ÷Öлá¼û¸ÃµØµã£¬Éó²éLaravelµÄ½Ó´ýÒ³Ãæ¡£
×°ÖÃLaravelÀ©Õ¹
LaravelÒѾԤװÖÃÁËÐí¶à³£ÓõÄÀ©Õ¹£¬¿ÉÊÇÓÐЩÀ©Õ¹¿ÉÄÜÐèÒªÊÖ¶¯×°Ö᣿ÉÒÔͨ¹ýComposerÀ´×°ÖÃLaravelÀ©Õ¹¡£ÀýÈ磬ÈôÊÇÐèҪװÖÃLaravelµÄdebugbarÀ©Õ¹£¬¿ÉÒÔÔËÐÐÒÔÏÂÏÂÁ
composer require barryvdh/laravel-debugbar
µÇ¼ºó¸´ÖÆ
×°ÖÃÍê³Éºó£¬ÐèÒªÔÚconfig/app.phpÎļþÖÐÌí¼ÓÒÔÏ´úÂëÀ´ÒýÓøÃÀ©Õ¹£º
'providers' => [ // ... Barryvdh\Debugbar\ServiceProvider::class, // ... ], 'aliases' => [ // ... 'Debugbar' => Barryvdh\Debugbar\Facade::class, // ... ],
µÇ¼ºó¸´ÖÆ
È»ºó¿ÉÒÔʹÓÃÒÔÏ´úÂëÔÚ´úÂëÖÐŲÓøÃÀ©Õ¹£º
Debugbar::info($someVariable);
µÇ¼ºó¸´ÖÆ
×ܽá
ʹÓÃComposer×°ÖÃLaravelÊǺÜÊÇÀû±ãºÍ¿ì½ÝµÄ¡£¿ÉÒÔͨ¹ý¼òÆÓµÄÏÂÁîÀ´½¨ÉèÏîÄ¿£¬×°ÖÃÒÀÀµ¹ØϵºÍÀ©Õ¹£¬ÌìÉúÓ¦ÓÃÃÜÔ¿ÒÔ¼°Ò»ÏµÁеĿª·¢Ê¹Ãü¡£ÔÚÏÖʵ¿ª·¢Àú³ÌÖУ¬LaravelΪ¿ª·¢Ö°Ô±ÌṩÁËÐí¶àÓÅÒìµÄ¹¦Ð§ºÍ¹¤¾ß£¬ÕâʹµÃ¿ª·¢ÍŶӿÉÒÔ¸ü¸ßЧµØ¾ÙÐпª·¢ÊÂÇé¡£
ÒÔÉϾÍÊÇlaravel composerÔõôװÖõÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡