×ðÁú¿­Ê±

Laravel¿ª·¢£ºÔõÑùʹÓÃLaravel ConfigÖÎÀíÉèÖã¿

laravelÊÇÒ»¿îÊ¢ÐеÄphp¿ò¼Ü £¬ËüÌṩÁËÖÚ¶àµÄÌØÕ÷ºÍ¹¤¾ßÀ´¼ò»¯webÓ¦ÓóÌÐòµÄ¿ª·¢Àú³Ì¡£ÆäÖÐÒ»¸öÖ÷ÒªµÄ¹¦Ð§ÊÇÉèÖÃÖÎÀí £¬ËüÔÊÐí¿ª·¢Õßͨ¹ýlaravel configÀ´ÖÎÀíÓ¦ÓóÌÐòÉèÖá£ÔÚ±¾ÎÄÖÐ £¬ÎÒÃǽ«ÏÈÈÝÔõÑùʹÓÃlaravel configÀ´ÖÎÀíÉèÖá£

ʲôÊÇLaravel Config£¿

Laravel ConfigÊÇÒ»¸öÉèÖÃÖÎÀíϵͳ £¬ËüÔÊÐí¿ª·¢Õß½«Ó¦ÓóÌÐòµÄÉèÖÃÊèÉ¢³öÀ´ £¬²¢ÔÚ´úÂëÖÐÇáËɵػá¼ûºÍʹÓÃÕâЩÉèÖá£ÕâʹµÃÓ¦ÓóÌÐòµÄÉèÖÃÔ½·¢ÎÞа £¬ÈÝÒ×ÖÎÀíºÍÒÆÖ²¡£Laravel ConfigʹÓÃPHPÊý×éÀ´´æ´¢ÉèÖà £¬²¢ÌṩÁËÒ»×éAPIÀ´»á¼ûºÍÐÞ¸ÄÕâЩÉèÖá£

ÉèÖÃÎļþ½á¹¹

Laravel ConfigµÄÉèÖÃÎļþ¿ÉÒÔ°²ÅÅÔÚconfigĿ¼Ï¡£Ä¬ÈÏÇéÐÎÏ £¬LaravelÌṩÁËһЩĬÈϵÄÉèÖÃÎļþ £¬Èçapp.php¡¢database.phpµÈ¡£Ã¿¸öÉèÖÃÎļþ¶¼°üÀ¨Ò»¸öPHPÊý×é £¬ÆäÖÐÿ¸ö¼ü´ú±íÒ»¸öÉèÖÃÏî £¬Ã¿¸öÖµ´ú±íÉèÖÃÏîµÄÖµ¡£ÀýÈç £¬app.php°üÀ¨Ó¦ÓóÌÐòµÄÃû³Æ¡¢ÇéÐΡ¢Ê±ÇøµÈÉèÖá£

»á¼ûÉèÖÃ

ͨ¹ýʹÓÃconfigº¯Êý £¬¿ÉÒÔÇáËɵػá¼ûÉèÖÃÏî £¬¸Ãº¯Êý½ÓÊÜÉèÖÃÏîµÄÃû³Æ×÷Ϊ²ÎÊý¡£ÀýÈç £¬Òª»á¼ûapp.phpÎļþÖеÄnameÉèÖÃÏî £¬¿ÉÒÔʹÓÃÒÔÏ´úÂ룺

$name = config('app.name');

µÇ¼ºó¸´ÖÆ

configº¯Êý·µ»ØÉèÖÃÏîµÄÖµ¡£ÈôÊÇÉèÖÃÏî²»±£´æ £¬Ôò·µ»Ønull¡£ÈôÊÇÒªÔÚÊÓͼÖÐʹÓÃÉèÖÃÏî £¬¿ÉÒÔʹÓÃÒÔÏ·½·¨£º

{{ config('app.name') }}

µÇ¼ºó¸´ÖÆ

ÐÞ¸ÄÉèÖÃ

¿ÉÒÔʹÓÃconfigº¯ÊýºÍÊý×éÓï·¨À´ÐÞ¸ÄÉèÖá£ÀýÈç £¬Òª½«app.phpÉèÖÃÎļþÖеÄtimezoneÉèÖÃÏîµÄÖµÉèÖÃΪ”Asia/Shanghai” £¬¿ÉÒÔʹÓÃÒÔÏ´úÂ룺

config(['app.timezone' => 'Asia/Shanghai']);

µÇ¼ºó¸´ÖÆ

Ò²¿ÉÒÔʹÓÃArtisanÏÂÁîÀ´ÐÞ¸ÄÉèÖá£ÀýÈç £¬Òª½«app.phpÉèÖÃÎļþÖеÄtimeoutÉèÖÃÏîµÄÖµÉèÖÃΪ300Ãë £¬¿ÉÒÔʹÓÃÒÔÏÂÏÂÁ

php artisan config:cache

µÇ¼ºó¸´ÖÆ

¸ÃÏÂÁˢÐÂÉèÖûº´æ £¬²¢ÖØÐÂÌìÉúÖØÐÂÐ޸ĺóµÄÉèÖûº´æÎļþ¡£

»º´æÉèÖÃ

µ±Å²ÓÃconfigº¯Êýʱ £¬Laravel»á´Óÿ¸öÉèÖÃÎļþ¶ÁÈ¡²¢±àÒëPHPÊý×é¡£ÕâÒâζ×ÅÔÚÓ¦ÓóÌÐòµÄÿ¸öÇëÇóÖж¼»á±¬·¢ÕâÖÖ²Ù×÷ £¬Õ⽫ӰÏìÓ¦ÓóÌÐòµÄÐÔÄÜ¡£ÎªÏàʶ¾öÕâ¸öÎÊÌâ £¬LaravelÌṩÁËÒ»¸öÏÂÁîÐй¤¾ßphp artisan config:cache £¬¸Ã¹¤¾ß½«»º´æËùÓÐÉèÖÃÎļþ²¢ÌìÉúÒ»¸ö»º´æÎļþ¡£¸Ã»º´æÎļþ°üÀ¨ËùÓÐÉèÖÃÎļþ¼°ÆäÖµµÄÕû¸öÊý×é £¬Òò´ËLaravel²»±ØÆÊÎö¶à¸öÎļþ¡£Õ⽫´ó´óÌá¸ßÓ¦ÓóÌÐòµÄÐÔÄÜ¡£

È»¶ø £¬Òª×¢ÖصÄÊÇ £¬Ò»µ©Ê¹ÓÃÁËphp artisan config:cacheÏÂÁîÌìÉúÁË»º´æÎļþ £¬ÔÚ¸ü¸ÄÉèÖÃÏîºó¶¼±ØÐèÔÙ´ÎÔËÐиÃÏÂÁî²Å»ªÊ¹¸ü¸ÄÉúЧ¡£²»È» £¬Ó¦ÓóÌÐò½«Ê¹Óûº´æÎļþÖеÄÉèÖÃÖµ¾ÙÐд¦Öóͷ£¡£

×ܽá

Laravel ConfigÊÇÒ»¸öÎÞаºÍÇ¿Ê¢µÄ¹¤¾ß £¬¿ÉÒÔ×ÊÖú¿ª·¢ÕßÇáËÉÖÎÀíÓ¦ÓóÌÐòµÄÉèÖá£ËüÌṩÁËÒ»ÖÖÀû±ãµÄ·½·¨À´ÊèÉ¢ÉèÖò¢ÔÚÓ¦ÓóÌÐòÖлá¼ûºÍÐÞ¸ÄËüÃÇ¡£Í¬Ê± £¬Í¨¹ýÉèÖûº´æ £¬Laravel ConfigÈ·±£Ó¦ÓóÌÐòµÄÐÔÄÜ £¬´Ó¶øʹÆä³ÉΪLaravel¿ª·¢µÄ±Ø±¸¹¤¾ßÖ®Ò»¡£

ÒÔÉϾÍÊÇLaravel¿ª·¢£ºÔõÑùʹÓÃLaravel ConfigÖÎÀíÉèÖ㿵ÄÏêϸÄÚÈÝ £¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

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

Ïà¹ØÐÂÎÅ

ÁªÏµ×ðÁú¿­Ê±

18523999891

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

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

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