thinkphpÔõôÔÚÏÂÁîÐÐ
thinkphpÊÇÒ»¿î¿ªÔ´µÄphp¿ò¼Ü£¬ËüÓµÓÐÖÚ¶àµÄÓŵ㣬È羫Á·¡¢Ò×ÓᢸßЧµÈµÈ¡£ÔÚÈÕ³£¿ª·¢ÖУ¬ÎÒÃÇʱ³£ÐèÒªÔÚÏÂÁîÐÐÖÐÖ´ÐÐijЩ²Ù×÷£¬ÀýÈ罨Éè¿ØÖÆÆ÷¡¢ÌìÉúÄ£×ӵȵȡ£ÄÇô£¬ÔõÑùÔÚÏÂÁîÐÐÖÐʹÓÃthinkphpÄØ£¿
Ò»¡¢×°ÖÃThinkPHP
Ê×ÏÈ£¬ÎÒÃÇÐèҪװÖÃThinkPHP¡£ÔÚ¹ÙÍøÉÏÏÂÔØ×îаæµÄѹËõ°ü£¬½âѹµ½ÍâµØÖ®ºó£¬Í¨¹ýÏÂÁîÐнøÈëµ½ThinkPHPµÄ¸ùĿ¼Ï£¬Ö´ÐÐÈçÏÂÏÂÁ
php think
µÇ¼ºó¸´ÖÆ
ÈôÊÇÀÖ³ÉÊä³öÁËThinkPHPµÄ°æ±¾ºÅµÈÐÅÏ¢£¬Ôò˵Ã÷×ðÁú¿Ê±×°ÖÃÀֳɡ£
¶þ¡¢ÏÂÁîÐÐÓ¦ÓÃ
Á¬Ã¦Ñ§Ï°¡°PHPÃâ·ÑѧϰÌõ¼Ç£¨ÉîÈ룩¡±£»
ÔÚThinkPHPÖУ¬ÎÒÃÇ¿ÉÒÔʹÓÃÏÂÁîÐÐÓ¦ÓÃÀ´Ö´ÐÐһЩ³£ÓõIJÙ×÷¡£ÏÂÁîÐÐÓ¦ÓÃÊÇÖ¸ÔÚÖնˣ¨ÏÂÁîÐУ©ÖÐÊäÈëһЩÏÂÁȻºóÖ´ÐÐÏìÓ¦µÄ²Ù×÷¡£ÀýÈ磬ÎÒÃÇ¿ÉÒÔʹÓÃÏÂÁîÐÐÓ¦ÓÃÀ´½¨Éè¿ØÖÆÆ÷¡¢ÌìÉúÄ£×ӵȵȡ£
£¨Ò»£©½¨Éè¿ØÖÆÆ÷
ÔÚÏÂÁîÐÐÖУ¬ÊäÈëÒÔÏ´úÂë¼´¿É½¨ÉèÒ»¸öÃûΪIndexµÄ¿ØÖÆÆ÷£º
php think make:controller Index
µÇ¼ºó¸´ÖÆ
ÕâÌõÏÂÁîµÄ¼ÄÒåÊÇÔÚÄ¿½ñÓ¦ÓõĿØÖÆÆ÷Ŀ¼Öн¨ÉèÒ»¸öÃûΪIndexµÄ¿ØÖÆÆ÷¡£
£¨¶þ£©ÌìÉúÄ£×Ó
ÔÚÏÂÁîÐÐÖУ¬ÊäÈëÒÔÏ´úÂë¼´¿Éƾ֤Êý¾Ý±íÌìÉú¶ÔÓ¦µÄÄ£×Ó£º
php think make:model User
µÇ¼ºó¸´ÖÆ
ÕâÌõÏÂÁîµÄ¼ÄÒåÊÇÔÚÄ¿½ñÓ¦ÓõÄÄ£×ÓĿ¼ÖÐÌìÉúÒ»¸öÃûΪUserµÄÄ£×Ó£¬»á×Ô¶¯¹ØÁªµ½userÊý¾Ý±í¡£
£¨Èý£©ÌìÉú±íµ¥ÑéÖ¤Æ÷
ÔÚÏÂÁîÐÐÖУ¬ÊäÈëÒÔÏ´úÂë¼´¿Éƾ֤Êý¾Ý±íÌìÉú¶ÔÓ¦µÄ±íµ¥ÑéÖ¤Æ÷£º
php think make:validate User
µÇ¼ºó¸´ÖÆ
ÕâÌõÏÂÁîµÄ¼ÄÒåÊÇÔÚÄ¿½ñÓ¦ÓõÄÑéÖ¤Æ÷Ŀ¼ÖÐÌìÉúÒ»¸öÃûΪUserµÄÑéÖ¤Æ÷£¬»á×Ô¶¯Æ¾Ö¤userÊý¾Ý±íÌìÉúÑéÖ¤¹æÔò¡£
Èý¡¢ÉèÖÃÏÂÁîÐÐÓ¦ÓÃ
ÔÚĬÈÏÇéÐÎÏ£¬ThinkPHPʹÓõÄÊÇCLIģʽÀ´ÔËÐÐÏÂÁîÐÐÓ¦Óá£ÈôÊÇÎÒÃÇÐèÒªÔÚWEBģʽÏÂÔËÐУ¬ÔòÐèÒªÐÞ¸ÄÉèÖÃÎļþ¡£·¿ªconfig/console.phpÎļþ£¬½«use_clioptionÑ¡ÏîÉèÖÃΪfalse¼´¿É¡£
ËÄ¡¢ÏÂÁîÐвÎÊýÆÊÎö
ÔÚThinkPHPÖУ¬ÎÒÃÇ¿ÉÒÔ×Ô½ç˵ÏÂÁîÐвÎÊýÀ´ÆÊÎö¡£ÏÂÃæÊÇÒ»¸öÀý×Ó£º
php think test:name --name ThinkPHP --age 5
µÇ¼ºó¸´ÖÆ
Õâ¸öÏÂÁîµÄ¼ÄÒåÊÇÔËÐÐtest¿ØÖÆÆ÷ÖеÄnameÒªÁ죬²¢×ª´ïÁ½¸ö²ÎÊý£¬»®·ÖΪnameºÍage¡£ÔÚ¿ØÖÆÆ÷ÖУ¬¿ÉÒÔͨ¹ýÈçÏÂÒªÁìÀ´»ñÈ¡ÕâÁ½¸ö²ÎÊý£º
$name = $this->input('name'); $age = $this->input('age');
µÇ¼ºó¸´ÖÆ
×ܽá
ͨ¹ýÉÏÊöÀý×Ó£¬ÎÒÃDz»ÄÑ·¢Ã÷£¬ÔÚÏÂÁîÐÐÖÐʹÓÃThinkPHPÊǺÜÊÇÈÝÒ׵ġ£½èÖúÏÂÁîÐÐÓ¦Óã¬ÎÒÃÇ¿ÉÒÔ¿ìËÙ¡¢Àû±ãµØ½¨Éè¿ØÖÆÆ÷¡¢ÌìÉúÄ£×ӵȵȡ£Í¬Ê±£¬Í¨¹ý²ÎÊýÆÊÎö£¬ÎÒÃÇ»¹¿ÉÒÔ×Ô½ç˵ÏÂÁîÐвÎÊýÀ´Öª×ã²î±ðµÄÐèÇó¡£
ÒÔÉϾÍÊÇthinkphpÔõôÔÚÏÂÁîÐеÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡