wampÇéÐÎ×°ÖÃthinkphp
wampÇéÐÎ×°ÖÃthinkphp
WAMP£¨Windows + Apache + MySQL + PHP£©ÊÇÒ»ÖÖÔÚWindows²Ù×÷ϵͳÏ´Web¿ª·¢ÇéÐεļ¯³ÉÈí¼þ°ü¡£¶øThinkPHPÊÇÒ»¸ö»ùÓÚPHPµÄWebÓ¦Óÿª·¢¿ò¼Ü¡£ÔÚWindowsÇéÐÎÖпª·¢WebÓ¦ÓóÌÐòʱ£¬ÎÒÃÇ¿ÉÒÔºÜÀû±ãµØʹÓÃWAMPºÍThinkPHPÀ´Íê³É¡£±¾ÎĽ«ÏÈÈÝÔõÑùÔÚWindowsϵͳÏÂ×°ÖÃWAMPÇéÐΣ¬²¢Ê¹ÓÃThinkPHP¿ò¼Ü¾ÙÐÐWebÓ¦ÓóÌÐòµÄ¿ª·¢¡£
Ò»¡¢WAMPÇéÐÎ×°ÖÃ
1.ÏÂÔØWAMP
¹ÙÍøµØµã£ºhttp://www.wampserver.com/en/
Á¬Ã¦Ñ§Ï°¡°PHPÃâ·ÑѧϰÌõ¼Ç£¨ÉîÈ룩¡±£»
ÏÂÔضÔÓ¦µÄ°æ±¾£¬Æ¾Ö¤×Ô¼ºµçÄÔ²Ù×÷ϵͳµÄλÊýÀ´Ñ¡Ôñx86»òx64°æ±¾µÄWAMP×°Öðü¡£
2.×°ÖÃWAMP
Ë«»÷ÏÂÔصÄWAMP×°Öðü£¬Æ¾Ö¤ÌáÐÑ×°Öü´¿É£¬Ò»Ñùƽ³£¼á³ÖĬÈÏÉèÖü´¿É¡£
3.Æô¶¯WAMP
×°ÖÃÍê³Éºó£¬»áÔÚWindowsϵͳÍÐÅÌÖзºÆðWAMPµÄͼ±ê£¬Ë«»÷·¿ªºó£¬¿ÉÒÔ¿´µ½WAMPЧÀÍÆ÷ÒѾÆô¶¯¡£
¶þ¡¢ThinkPHP¿ò¼Ü×°ÖÃ
1.ÏÂÔØThinkPHP¿ò¼Ü
¹ÙÍøµØµã£ºhttp://www.thinkphp.cn/
ÔÚÊ×Ò³ÉÏ·½µÄ¡°ÏÂÔØ¡±Ñ¡ÏÖÐÕÒµ½¡°ThinkPHP5.X£¨LTS£©¡±²¢ÏÂÔØ¡£
2.ÉèÖÃThinkPHP
½«ÏÂÔØÏÂÀ´µÄѹËõÎļþ½âѹËõµ½WAMPЧÀÍÆ÷ĬÈϵÄWeb¸ùĿ¼Ï£¨Ä¬ÒÔΪC:wampwww£©£¬»ñµÃÈçÏÂĿ¼½á¹¹£º
www ©¦ favicon.ico ©¦ index.php ©¦ ©¸©¤©¤©¤thinkphp ©¦ ©¦ ...
µÇ¼ºó¸´ÖÆ
ÆäÖУ¬thinkphpÎļþ¼ÐÊÇThinkPHP¿ò¼ÜµÄ½¹µãÎļþ¡£
½Ó×Å£¬ÐÞ¸ÄWAMPµÄApacheÉèÖÃÎļþ£¨httpd.conf£©¡£
ÕÒµ½ DocumentRoot ºÍ Directory ±êÇ©£¬½«Á½ÕßÖ¸ÏòÊʲŽâѹËõµÄĿ¼£¬´úÂëÈçÏ£º
DocumentRoot "C:/wamp/www" <Directory "C:/wamp/www/">
µÇ¼ºó¸´ÖÆ
×¢Öؽ«Â·¾¶¸ÄΪ×Ô¼º½âѹËõµÄĿ¼·¾¶¡£
ÐÞ¸ÄÍê³Éºó£¬ÉúÑÄhttpd.confÎļþ²¢ÖØÆôApacheЧÀÍ£¬Ê¹ÉèÖÃÉúЧ¡£
Èý¡¢½¨Éè²¢ÔËÐеÚÒ»¸öThinkPHP³ÌÐò
1.н¨Ò»¸öÏîÄ¿
ÔÚWAMPµÄWeb¸ùĿ¼ÏÂн¨Ò»¸öÎļþ¼Ð×÷ΪÎÒÃǵÄÏîÄ¿£¬ÀýÈç myproject¡£
2.½¨ÉèÏîÄ¿Îļþ½á¹¹
ÔÚ¸ÃÎļþ¼ÐÏÂн¨ÈçÏÂĿ¼½á¹¹£º
www ©¦ favicon.ico ©¦ index.php ©¦ ©¸©¤©¤©¤myproject ©¦ ©¸©¤©¤©¤application ©¦ ©¦ ©¸©¤©¤©¤index ©¦ ©¦ ©¦ ©¸©¤©¤©¤controller ©¦ ©¦ ©¦ ©¦ Index.php ©¦ ©¦ ©¦ ©¸©¤©¤©¤view ©¦ ©¦ ©¦ ©¸©¤©¤©¤config.php ©¦ ©¦ ©¦ ©¦ ©¦ ©¸©¤©¤©¤config ©¦ ©¦ ©¦ config.php ©¦ ©¦ ©¦ ©¦ ©¦ ©¸©¤©¤©¤ ... ©¦ ©¦ ©¦ ©À©¤public ©¦ ©¦ ©À©¤index.php ©¦ ©¦ ©¸©¤logo.png ©¦ ©¦ ©¦ ©À©¤thinkphp ©¦ ©¦ ©¸©¤ ...
µÇ¼ºó¸´ÖÆ
ÆäÖУ¬applicationÎļþ¼ÐÊÇÓ¦ÓÃĿ¼£¬indexÊÇÓ¦ÓÃÃû£¬controllerÊÇ¿ØÖÆÆ÷Ŀ¼£¬Index.phpÊÇ¿ØÖÆÆ÷Îļþ£¬viewÊÇÊÓͼĿ¼£¬config.phpÊÇÉèÖÃÎļþ£»configÎļþ¼ÐÖаüÀ¨ÁËÉèÖÃÎļþ¡£publicÊǹ«¹²ÎļþĿ¼£¬ÄÚÀïÖ»ÓÐÒ»¸öÈë¿ÚÎļþindex.php¡£thinkphpÊÇThinkPHP¿ò¼Ü½¹µãÎļþ¡£
3.±àд¿ØÖÆÆ÷´úÂë
ÔÚControllerĿ¼ÏÂн¨Index.phpÎļþ£¬´úÂëÈçÏ£º
<?php namespace appindexcontroller; use thinkController; class Index extends Controller { public function index() { return 'Hello, ThinkPHP5!'; } }
µÇ¼ºó¸´ÖÆ
ÆäÖÐ namespace ½ç˵Á˸ÿØÖÆÆ÷ËùÔÚµÄÃüÃû¿Õ¼ä£»useÒýÈëÁË¿ØÖÆÆ÷ÐèÒªµÄÀà¿â£¬²¢¼ÌÐøÁËthinkControllerÀࣻindexÒªÁìΪ¿ØÖÆÆ÷µÄÒªÁ죬¿ÉÒÔ·µ»Øí§Òâ×Ö·û´®¡£
4.ÔËÐгÌÐò
·¿ªä¯ÀÀÆ÷²¢»á¼ûhttp://localhost/myproject/public/index.php/index/index£¬¼´¿É¿´µ½³ÌÐò·µ»ØµÄ×Ö·û´® “Hello, ThinkPHP5!”¡£
ÖÁ´Ë£¬Ò»¸ö»ùÓÚWAMPÇéÐκÍThinkPHP¿ò¼ÜµÄWebÓ¦ÓóÌÐòÒѾÀÖ³ÉÔËÐС£
×ܽá
±¾ÎÄÏÈÈÝÁËÔÚWindowsϵͳÏÂ×°ÖÃWAMPÇéÐκÍThinkPHP¿ò¼Ü£¬²¢ÑÝʾÁËÔõÑù½¨ÉèºÍÔËÐÐÒ»¸ö×î¼òÆÓµÄWebÓ¦ÓóÌÐò¡£Ê¹Óü¯³É¿ª·¢ÇéÐοÉÒÔ¼«´óµØÌá¸ßWeb¿ª·¢Ð§ÂÊ£¬¶øʹÓÿò¼ÜÔò¿ÉÒÔÈóÌÐòÔ½·¢¹æ·¶»¯£¬Ò×ÓÚά»¤ºÍÉý¼¶¡£Ï£Íû¶Ô¸÷ÈËÓÐËù×ÊÖú¡£
ÒÔÉϾÍÊÇwampÇéÐÎ×°ÖÃthinkphpµÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡