ÔõÑùʹÓÃThinkPHP6¾ÙÐÐÎļþ¼ÓÃÜÏ¢ÕùÃܲÙ×÷£¿
ÔÚÅÌËã»úʱ´ú£¬Êý¾ÝÇå¾²Ò»Ö±ÊǸöÓÀºãÎȹ̵Ļ°Ìâ¡£ÆñÂÛÄúÊÇ´¦ÀíһЩСÎÒ˽ÈËÒþ˽Êý¾Ý£¬ÕÕ¾ÉÔÚ´¦Àí½ðÈÚÊý¾Ý£¬Êý¾ÝÇå¾²¶¼ÊÇÖÁ¹ØÖ÷ÒªµÄ¡£ÎªÁËÓÐÓõر£»¤Ãô¸ÐÊý¾Ý£¬ÎÒÃÇͨ³£¶¼»á½ÓÄɼÓÃܵIJ½·¥À´È·±£Êý¾ÝµÄÇå¾²¡£ÔÚphp¿ª·¢ÁìÓòÖУ¬thinkphpÊÇÒ»¿îºÜÊÇÊ¢ÐеĿª·¢¿ò¼Ü£¬ËüÌṩÁËÐí¶àÓÐÓõĹ¦Ð§ºÍ¹¤¾ß£¬ÆäÖаüÀ¨Îļþ¼ÓÃÜÏ¢ÕùÃܲÙ×÷¡£±¾ÎĽ«ÏÈÈÝÔõÑùʹÓÃthinkphp6¾ÙÐÐÎļþ¼ÓÃÜÏ¢ÕùÃܲÙ×÷¡£
Ò»¡¢×°ÖÃThinkPHP6
Ê×ÏÈ£¬ÎÒÃÇÐèÒªÔÚÎÒÃǵĿª·¢ÇéÐÎÖÐ×°ÖÃThinkPHP6¡£¿ÉÒÔͨ¹ýÒÔÏÂÏÂÁîʹÓÃComposerÀ´×°ÖÃThinkPHP6£º
composer create-project topthink/think myproject
µÇ¼ºó¸´ÖÆ
Õ⽫×ÊÖúÄú½¨ÉèÒ»¸öÃûΪ¡°myproject¡±µÄÎļþ¼Ð¡£ÔÚ´ËÎļþ¼ÐÖУ¬Äú½«ÕÒµ½Ò»¸öÃûΪ¡°think¡±µÄ¿ÉÖ´ÐÐÎļþ¡£Ê¹ÓÃÒÔÏÂÏÂÁîÆô¶¯ThinkPHP6¿ª·¢Ð§ÀÍÆ÷£º
php think run
µÇ¼ºó¸´ÖÆ
Õ⽫Æô¶¯Î»ÓÚhttp://localhost:8000µÄWebЧÀÍÆ÷¡£ÏÖÔÚ£¬ÄúÒѾ׼±¸ÐÒ¿÷ThinkPHP6ÖÐ×îÏȾÙÐÐÎļþ¼ÓÃÜÏ¢ÕùÃܲÙ×÷ÁË¡£
Á¬Ã¦Ñ§Ï°¡°PHPÃâ·ÑѧϰÌõ¼Ç£¨ÉîÈ룩¡±£»
¶þ¡¢Îļþ¼ÓÃÜ
ÔÚThinkPHP6ÖоÙÐÐÎļþ¼ÓÃܺÜÊǼòÆÓ¡£ÄúÖ»ÐèÒªÔÚ¿ØÖÆÆ÷ÖÐÖ´ÐÐÒÔÏ´úÂ룺
use thinkacadeFilesystem; $fileContent = Filesystem::read('path/to/file'); $encryptedFileContent = openssl_encrypt($fileContent , 'AES-256-CBC', 'encryption_key', 0, 'encryption_iv'); file_put_contents('path/to/encrypted_file', $encryptedFileContent);
µÇ¼ºó¸´ÖÆ
Õâ¶Î´úÂ뽫Ê×ÏÈʹÓÃFilesystemÀàÖеÄread£¨£©ÒªÁì¶ÁÈ¡Ò»¸öÎļþµÄÄÚÈÝ¡£È»ºó£¬½«ÎļþÄÚÈÝת´ï¸øopenssl_encrypt£¨£©º¯ÊýÀ´¼ÓÃÜ¡£Ôڴ˺¯ÊýÖУ¬Äú¿ÉÒÔÑ¡Ôñ¼ÓÃÜËã·¨¡¢¼ÓÃÜÃÜÔ¿ºÍ¼ÓÃÜÏòÁ¿¡£ÎļþÄÚÈݱ»¼ÓÃܺ󣬽«Ê¹ÓÃfile_put_contents£¨£©º¯Êý½«Æä´æ´¢µ½ÁíÒ»¸öλÖá£
Èý¡¢Îļþ½âÃÜ
ÔÚ½«Îļþ¼ÓÃܺó£¬Äú¿ÉÒÔʹÓÃÒÔÏ´úÂëÀ´¾ÙÐÐÎļþ½âÃÜ£º
$encryptedFileContent = Filesystem::read('path/to/encrypted_file'); $decryptedFileContent = openssl_decrypt($encryptedFileContent, 'AES-256-CBC', 'encryption_key', 0, 'encryption_iv'); file_put_contents('path/to/decrypted_file', $decryptedFileContent);
µÇ¼ºó¸´ÖÆ
Õâ¶Î´úÂ뽫Ê×ÏÈʹÓÃFilesystemÀàÖеÄread£¨£©ÒªÁì¶ÁÈ¡¼ÓÃÜÎļþµÄÄÚÈÝ¡£È»ºó£¬½«ÄÚÈÝת´ï¸øopenssl_decrypt£¨£©º¯ÊýÀ´½âÃÜ¡£Ôڴ˺¯ÊýÖУ¬Äú¿ÉÒÔÑ¡Ôñ½âÃÜËã·¨¡¢½âÃÜÃÜÔ¿Ï¢ÕùÃÜÏòÁ¿¡£½âÃÜÎļþÄÚÈݺ󣬽«Ê¹ÓÃfile_put_contents£¨£©º¯Êý½«Æä´æ´¢µ½ÁíÒ»¸öλÖá£
ËÄ¡¢½¨Òé
ËäÈ»ÔÚThinkPHP6ÖоÙÐÐÎļþ¼ÓÃÜÏ¢ÕùÃܲÙ×÷ºÜÊÇÈÝÒ×£¬¿ÉÊÇÔÚÏÖʵӦÓÃÖУ¬ÄúÐèҪעÖØÒÔϼ¸µã£º
Çå¾²ÐÔ£ºÔÚ¼ÓÃÜÏ¢ÕùÃܲÙ×÷ÖÐʹÓÃÇå¾²ÃÜÔ¿ÊǺÜÊÇÖ÷ÒªµÄ¡£ÇëÈ·±£ÔÚÉú²úÇéÐÎÖÐʹÓøßÆ·ÖʵÄÃÜÔ¿¡£
Ëã·¨£ºÑ¡ÔñÒ»¸öºÏÊʵļÓÃÜËã·¨¹ØÓÚÐÅÏ¢Çå¾²ÖÁ¹ØÖ÷Òª¡£ÇëÉóÉ÷Ñ¡Ôñ¡£
ÎļþÀàÐÍ£º²»½¨Òé¼ÓÃÜ»ò½âÃÜÖîÈçÊÓƵºÍÒôƵµÈ´óÐÍÎļþ¡£ÕâЩÎļþͨ³£¾ßÓи߱ÈÌØÂʺͶÌÒªº¦×Ö£¬Õâ¿ÉÄܻᵼÖÈÎÃüÜ»ò½âÃÜʧ°Ü»òʹÓùý¶àµÄÅÌËã×ÊÔ´¡£
×ÜÖ®£¬ÔÚʹÓÃThinkPHP6¾ÙÐÐÎļþ¼ÓÃÜÏ¢ÕùÃܲÙ×÷ʱ£¬ÄúÐèÒªÔÚÉú²úÇéÐÎÖÐÓÅÏÈ˼Á¿Êý¾ÝÇå¾²¡£ÕâЩ²Ù×÷¶¼ºÜ¼òÆÓ£¬¿ÉÊÇÈôÊÇÄú²»¿É½ÓÄÉÏìÓ¦µÄÇå¾²²½·¥À´±£»¤Óû§Êý¾Ý£¬ÄÇôÕâЩ²Ù×÷¾ÍºÁÎÞÒâÒå¡£
ÒÔÉϾÍÊÇÔõÑùʹÓÃThinkPHP6¾ÙÐÐÎļþ¼ÓÃÜÏ¢ÕùÃܲÙ×÷£¿µÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡