×ðÁú¿­Ê±

ThinkPHP6µÄ³£¼ûÎÊÌâ½â¾ö²½·¥ÓÐÄÄЩ £¿

thinkphp6ÊÇÒ»¿î¹ãÊܽӴýµÄphp¿ò¼Ü£¬ËäÈ»ÆäÓµÓÐÐí¶àÓÅÊƺͱã½ÝÐÔ£¬¿ÉÊÇÎÒÃÇÔÚÏÖʵʹÓÃÖÐÈÔÈ»»áÔâÓöһЩ³£¼ûµÄÎÊÌ⣬ÈôÊDz»ÊµÊ±½â¾öÕâЩÎÊÌ⣬¾ÍÓпÉÄÜ×è°­ÏîÄ¿µÄÕý³£¾ÙÐС£±¾ÎĽ«ÏÈÈÝһЩ³£¼ûÎÊÌâµÄ½â¾ö²½·¥¡£

1.Êý¾Ý¿âÅþÁ¬ÎÊÌâ

ÔÚʹÓÃThinkPHP6¾ÙÐÐÊý¾Ý¿â²Ù×÷ʱ£¬¿ÉÄÜ»áÔâÓöÎÞ·¨ÅþÁ¬Êý¾Ý¿âµÄÎÊÌâ¡£Õâʱ¼ä£¬ÎÒÃÇÓ¦¸ÃÊ×Ïȼì²éÊý¾Ý¿âµÄÉèÖÃÎļþ¡£ÔÚconfig/database.phpÖУ¬Ó¦¸ÃÉèÖÃ׼ȷµÄÊý¾Ý¿âÅþÁ¬ÐÅÏ¢¡£ÀýÈ磺

return [
    'type'        => 'mysql',
    'hostname'    => 'localhost',
    'database'    => 'test',
    'username'    => 'root',
    'password'    => '',
    'hostport'    => '',
    'charset'     => 'utf8mb4',
    'prefix'      => '',
    'debug'       => true,
    'deploy'      => 0,
    'rw_separate' => false,
    'master_num'  => 1,
    'slave_no'    => '',
    'fields_strict' => true,
    'resultset_type' => 'array',
    'auto_timestamp' => false,
    'datetime_format' => 'Y-m-d H:i:s',
    'sql_explain' => false,
];

µÇ¼ºó¸´ÖÆ

2.ÎÞ·¨¼ÓÔØÄ£°åÎļþ

ÔÚʹÓÃThinkPHP6µÄÄ£°å¹¦Ð§Ê±£¬ÓÐʱ¼ä»áÔâÓöÎÞ·¨¼ÓÔØÄ£°åÎļþµÄÎÊÌâ¡£Õâʱ¼ä£¬ÎÒÃÇÓ¦¸Ã¼ì²éÄ£°åÎļþ·¾¶ÊÇ·ñ׼ȷ¡£ÎÒÃÇ¿ÉÒÔÔÚconfig/view.phpÖÐÉèÖÃÄ£°åÎļþµÄ·¾¶¡£ÀýÈ磺

return [
    // Ä£°å·¾¶
    'view_path'    => './template/',
];

µÇ¼ºó¸´ÖÆ

±ðµÄ£¬ÎÒÃÇ»¹ÐèҪȷ¶¨Ä£°åÎļþµÄºó׺ÃûÊÇ·ñ׼ȷ¡£ÔÚconfig/view.phpÖУ¬ÎÒÃÇ¿ÉÒÔÉèÖÃÄ£°åÎļþµÄºó׺Ãû£º

return [
    'view_suffix'  => 'html',
];

µÇ¼ºó¸´ÖÆ

»òÕߣ¬ÔÚControllerÖеÄÒªÁìÖÐŲÓÃÄ£°åʱ£¬Ò²¿ÉÒÔͨ¹ýµÚ¶þ¸ö²ÎÊýÀ´Ö¸¶¨Ä£°åÎļþµÄºó׺Ãû£º

Á¬Ã¦Ñ§Ï°¡°PHPÃâ·ÑѧϰÌõ¼Ç£¨ÉîÈ룩¡± £»

return $this->fetch('index', 'html');

µÇ¼ºó¸´ÖÆ

3.·ÓÉÎÊÌâ

ÔÚʹÓÃThinkPHP6µÄ·ÓÉ»úÖÆʱ£¬ÓÐʱ¼ä»áÔâÓö·ÓÉÎÞ·¨Õý³£ÊÂÇéµÄÎÊÌâ¡£Õâʱ¼ä£¬ÎÒÃÇÓ¦¸ÃÏȼì²é·ÓÉÊÇ·ñ׼ȷÉèÖá£ÔÚconfig/route.phpÖУ¬ÎÒÃÇ¿ÉÒÔÉèÖ÷ÓɹæÔò¡£ÀýÈ磺

use thinkacadeRoute;

Route::get('/user/:id', 'index/User/read');

µÇ¼ºó¸´ÖÆ

ÆäÖУ¬/user/:idÌåÏÖÒ»¸ö·ÓɹæÔò£¬:idÌåÏÖÒ»¸öռλ·û£¬ÌåÏÖURLÖеÄÒ»¸ö±äÁ¿¡£ÎÒÃÇÐèҪȷ±£Â·ÓɹæÔò׼ȷÉèÖã¬ÇÒռλ·ûÃû³ÆÓë¶ÔÓ¦²ÎÊýÃû³ÆÒ»Ö¡£

4.ÎļþÉÏ´«ÎÊÌâ

ÔÚʹÓÃThinkPHP6¾ÙÐÐÎļþÉÏ´«Ê±£¬ÓÐʱ¼ä»áÔâÓöÎÞ·¨Õý³£ÉÏ´«ÎļþµÄÎÊÌâ¡£Õâʱ¼ä£¬ÎÒÃÇÓ¦¸Ã¼ì²éÉÏ´«Îļþ¾ÞϸÊÇ·ñÁè¼ÝÏÞÖÆ¡£ÔÚconfig/upload.phpÖУ¬ÎÒÃÇ¿ÉÒÔÉèÖÃÉÏ´«Îļþ¾ÞϸµÄÏÞÖÆ¡£ÀýÈ磺

return [
    'default' => [
        'size' => 1024 * 1024 * 2, //Îļþ¾ÞϸÏÞÖÆΪ2M
    ],
];

µÇ¼ºó¸´ÖÆ

±ðµÄ£¬ÎÒÃÇ»¹ÐèҪȷ±£ÉÏ´«ÎļþµÄĿ¼±£´æÇÒ¿Éд¡£ÎÒÃÇ¿ÉÒÔÔÚconfig/filesystem.phpÖÐÉèÖÃÎļþÉÏ´«Ä¿Â¼µÄ·¾¶£º

return [
    'default' => 'local',
    'disks'   => [
        'local' => [
            'type' => 'local',
            'root' => app()->getRuntimePath() . 'upload',
        ],
    ],
];

µÇ¼ºó¸´ÖÆ

ÈôÊÇĿ¼²»±£´æ£¬ÔòÐèÒªÊÖ¶¯½¨Éè²¢ÉèÖÃ׼ȷȨÏÞ¡£

×ÜÖ®£¬Ê¹ÓÃThinkPHP6¿ò¼Üʱ£¬ÔâÓöһЩ³£¼ûÎÊÌâÊdz£ÓеÄÊÂÇé¡£ÎÒÃÇÐèҪʵʱ²éÕÒÎÊÌâȪԴ£¬È»ºóʵÑé׎â¾öÎÊÌâ¡£±¾ÎÄÖ»ÏÈÈÝÁËһЩ³£¼ûÎÊÌâµÄ½â¾ö²½·¥£¬ÎÊÌâµÄ¶àÑùÐÔÓëÖØ´óÐÔÊÇÎÒÃÇÔÚÏÖʵʹÓÃÖÐÓ¦¸ÃÉî¿ÌÊìϤµ½µÄ¡£

ÒÔÉϾÍÊÇThinkPHP6µÄ³£¼ûÎÊÌâ½â¾ö²½·¥ÓÐÄÄЩ £¿µÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

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

Ïà¹ØÐÂÎÅ

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

18523999891

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

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

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