>  기사  >  백엔드 개발  >  Band of Brothers ThinkPHP3.1 기본 비디오 튜토리얼에 대한 권장 리소스

Band of Brothers ThinkPHP3.1 기본 비디오 튜토리얼에 대한 권장 리소스

黄舟
黄舟원래의
2017-08-31 09:54:591909검색

ThinkPHP는 엔터프라이즈급 애플리케이션 개발과 민첩한 WEB 애플리케이션 개발을 단순화하기 위해 탄생했습니다. 2006년 초에 처음 탄생했으며 2007년 설날에 공식적으로 ThinkPHP로 이름이 바뀌었고 Apache2 오픈 소스 계약에 따라 출시되었습니다. ThinkPHP는 탄생부터 단순하고 실용적인 디자인 원칙을 고수해 왔으며 뛰어난 성능과 최소한의 코드를 유지하면서도 사용 편의성에도 중점을 두었습니다. 그리고 커뮤니티 팀의 적극적인 참여로 많은 독창적인 기능과 특징을 가지고 있으며 사용 편의성, 확장성 및 성능 측면에서 지속적으로 최적화되고 개선됩니다.

Band of Brothers ThinkPHP3.1 기본 비디오 튜토리얼에 대한 권장 리소스

강좌 재생 주소: http://www.php.cn/course/383.html

선생님의 강의 스타일:

선생님의 강의는 간단하고 깊이 있고 명확합니다. 논리적 사고력을 사용하여 학생들의 관심을 끌고 이성을 사용하여 교실 교육 과정을 제어합니다. 교수법은 위트가 넘칩니다. 다양한 교수법과 기술을 쉽게 사용할 수 있으며, 다듬은 흔적 없이 자유롭고 적절하게 사용할 수 있습니다.

이 영상에서 더 어려운 점은: 그룹화, 페이지 점프 및 Ajax:

1. 다중 애플리케이션 구성 기술
2. 페이지 점프
$this->success(' 쿼리 성공',U('사용자/테스트'));
$this->redirect('사용자/테스트','',5,'페이지가 점프 중입니다');
4 Ajax 기술

前后台公用公共配置文件:  
  
$ pwd  
/cygdrive/c/wamp/www/thinkphp5/Admin/Conf  
  
Administrator@QCEE61NZ66FEX2D /cygdrive/c/wamp/www/thinkphp5/Admin/Conf  
$ ls  
config.php  
  
Administrator@QCEE61NZ66FEX2D /cygdrive/c/wamp/www/thinkphp5/Admin/Conf  
$ cat config.php  
<?php  
$arr=include &#39;./config.php&#39;;  
  
$arr2=array(  
  
);  
return  array_merge($arr,$arr2);  
  
  
?>  
  
// 当前目录下的config.php,这个当前是指主入口的路径:  
  
  
$arr=include &#39;./config.php&#39;;  
  
  
  
公用配置文件:  
$ pwd  
/cygdrive/c/wamp/www/thinkphp5  
  
Administrator@QCEE61NZ66FEX2D /cygdrive/c/wamp/www/thinkphp5  
$ ls -ltr config.php  
-rwxrwx---+ 1 Administrators None 393 五月  9 13:14 config.php  
  
Administrator@QCEE61NZ66FEX2D /cygdrive/c/wamp/www/thinkphp5  
$ cat config.php  
<?php  
return array(  
        //&#39;配置项&#39;=>&#39;配置值&#39;  
        &#39;TMPL_L_DELIM&#39;=>&#39;<{&#39;,   //配置左定界符  
        &#39;TMPL_R_DELIM&#39;=>&#39;}>&#39;,    //配置右定界符  
        &#39;DB_PREFIX&#39;=>&#39;&#39;,     //设置表前缀  
        &#39;DB_DSN&#39;=>&#39;mysql://root:1234567@192.168.32.79:3306/devops&#39;, //DSN方式配置数据库信息  
        &#39;SHOW_PAGE_TRACE&#39;=>true,//开启页面Trace  
        /* &#39;URL_ROUTER_ON&#39;=>true,  
        &#39;URL_ROUTE_RULES&#39;=>array(  
         &#39;:id/:num&#39;=>&#39;Index/index&#39;,  
         ), */  
);  
?>  
Administrator@QCEE61NZ66FEX2D /cygdrive/c/wamp/www/thinkphp5  
  
  
  
  
  
thinkphp 分组机制:  
  
<?php  
//1.确定应用名称 Home  
  
define(&#39;APP_NAME&#39;,&#39;App&#39;);  
  
//2. 确定应用路径  ./Home 当前目录 index.php的当前目录 前台文件夹  
  
define(&#39;APP_PATH&#39;,&#39;./App/&#39;);  
//开启调试模式  
  
 define(&#39;APP_DEBUG&#39;,true);  
//4.引入核心文件 include 引入的东西错误 代码继续运行  require 出错立即结束  
  
require &#39;./ThinkPHP/ThinkPHP.php&#39;;  
  
?>  
  
  
  
  
&#39;APP_GROUP_LIST&#39; => &#39;Home,Admin&#39;, //项目分组设定  
&#39;DEFAULT_GROUP&#39;  => &#39;Home&#39;, //默认分组  
  
  
  
  
  
在同一个应用下,再分不同的应用:  
  
$ pwd  
/cygdrive/c/wamp/www/thinkphp6/App/Lib/Action  
  
Administrator@QCEE61NZ66FEX2D /cygdrive/c/wamp/www/thinkphp6/App/Lib/Action  
$ ls  
Admin  Home  IndexAction.class.php  
  
  
整个应用叫app应用:  
  
<?php  
//1.确定应用名称 Home  
  
define(&#39;APP_NAME&#39;,&#39;App&#39;);  
  
//2. 确定应用路径  ./Home 当前目录 index.php的当前目录 前台文件夹  
  
define(&#39;APP_PATH&#39;,&#39;./App/&#39;);  
//开启调试模式  
  
 define(&#39;APP_DEBUG&#39;,true);  
//4.引入核心文件 include 引入的东西错误 代码继续运行  require 出错立即结束  
  
require &#39;./ThinkPHP/ThinkPHP.php&#39;;  
  
?>  
  
  
  
  
  
  
推荐使用分应用的方式,而不是分组  
  
  
分应用情况下的访问方式,多应用配置技巧:  
  
  
$ pwd  
/cygdrive/c/wamp/www/thinkphp5  
  
Administrator@QCEE61NZ66FEX2D /cygdrive/c/wamp/www/thinkphp5  
$ ls  
Admin  admin.php  config.php  Home  index.php  ThinkPHP  
  
  
Home前台应用文件夹:  
  
Admin后台应用文件夹:  
  
http://localhost/thinkphp5/admin.php  
  
http://localhost/thinkphp5/index.php  
  
  
  
//页面跳转:  
  
<?php  
// 本类由系统自动生成,仅供测试用途  
class IndexAction extends Action {  
    public function index(){  
    echo "come in Home!";  
    $user=M(&#39;user&#39;);  
    $arr=$user->select();  
    dump($arr);  
    //分配给前台,表示为list   
    $this->assign(&#39;list&#39;,&#39;$arr&#39;);  
    $this->display();  
    }  
}  
  
  
  
前端页面:  
<!doctype html>  
<html lang="en">  
 <head>  
  <meta charset="UTF-8">  
  <meta name="Generator" content="EditPlus®">  
  <meta name="Author" content="">  
  <meta name="Keywords" content="">  
  <meta name="Description" content="">  
  <title>Document</title>  
 </head>  
 <body>  
    
  <table border=&#39;1&#39; width=&#39;500&#39;>  
  <foreach name=&#39;list&#39; item=&#39;vo&#39;>  
  
  <tr><td><{$vo.username}></td></tr>  
  
  </foreach>  
  
  </table>  
 </body>  
</html>  
  
  
//超链接:  
  
<!doctype html>  
<html lang="en">  
 <head>  
  <meta charset="UTF-8">  
  <meta name="Generator" content="EditPlus®">  
  <meta name="Author" content="">  
  <meta name="Keywords" content="">  
  <meta name="Description" content="">  
  <title>Document</title>  
 </head>  
 <body>  
    
  <table border=&#39;1&#39; width=&#39;500&#39;>  
  <foreach name=&#39;list&#39; item=&#39;vo&#39;>  
  
  <tr><td><a href="__URL__/info?id=<{$vo.id}>"><{$vo.username}></a></td></tr>  
  
  </foreach>  
  
  </table>  
 </body>  
</html>  
  
  
  
  
<?php  
// 本类由系统自动生成,仅供测试用途  
class IndexAction extends Action {  
    public function index(){  
    echo "come in Home!";  
    $user=M(&#39;user&#39;);  
    $arr=$user->select();  
    dump($arr);  
    //分配给前台,表示为list   
    $this->assign(&#39;list&#39;,$arr);  
    $this->display();  
    }  
      
    public function info(){  
        $id=$_GET[&#39;id&#39;];  
        $user=M(&#39;user&#39;);  
        $arr=$user->find($id);  
        dump($arr);  
        if ($arr){  
            $this->success(&#39;index&#39;);  
        }  
        else {  
            //失败后自动跳转到上一页  
            $this->error(&#39;查询失败&#39;);  
        }  
        $this->assign(&#39;list&#39;,$arr);  
        $this->display();  
    }  
}  
  
  
//redirect 跳转:  
  
<?php  
// 本类由系统自动生成,仅供测试用途  
class IndexAction extends Action {  
    public function index(){  
    echo "come in Home!";  
    $user=M(&#39;user&#39;);  
    $arr=$user->select();  
    dump($arr);  
    //分配给前台,表示为list   
    $this->assign(&#39;list&#39;,$arr);  
    $this->display();  
    }  
      
    public function info(){  
        $id=$_GET[&#39;id&#39;];  
        $user=M(&#39;user&#39;);  
        $arr=$user->find(100);  
        dump($arr);  
        if ($arr){  
            $this->success(&#39;index&#39;);  
        }  
        else {  
            //失败后自动跳转到上一页  
            $this->redirect(&#39;User/index&#39;);  
        }  
        $this->assign(&#39;list&#39;,$arr);  
        $this->display();  
    }  
}  
  
  
跳转到:  
http://localhost/thinkphp5/index.php/User/index  
  
User/index 页面  
  
  
  
Ajax 技巧:  
  
  
  
在框架里面,脚本都是被方法所取代  
  
  
<!doctype html>  
<html lang="en">  
 <head>  
  <meta charset="UTF-8">  
  <meta name="Generator" content="EditPlus®">  
  <meta name="Author" content="">  
  <meta name="Keywords" content="">  
  <meta name="Description" content="">  
  <title>Document</title>  
  <script src="__PUBLIC__/Js/jquery.js"></script>  
  <script>  
  $(function(){  
  $(&#39;button&#39;).bind(&#39;click&#39;,function(){  
   
    $.get(&#39;__URL__/getAjax&#39;,function(jdata){  
    <!--alert (JSON.stringify(data));-->  
    if (jdata.status==1){  
    alert(jdata.data);  
    }  
  });  
  });  
     
   });  
  
    
  </script>  
 </head>  
 <body>  
   <div style=&#39;height:50px;background:yellow&#39; id=&#39;did&#39;></div>  
   <button>点击</button>  
   <script>  
     document.write(new Date());  
     </script>  
 </body>  
</html>  
  
  
<?php  
class IndexAction extends Action {  
      
    public function index(){  
        $this->display();  
    }  
      
    public function getAjax(){  
        //echo &#39;aaaaaaa&#39;;  
        $this->ajaxReturn(&#39;这里是数据&#39;,&#39;信息1&#39;,1);  
    }  
  
}

위 내용은 Band of Brothers ThinkPHP3.1 기본 비디오 튜토리얼에 대한 권장 리소스의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!

성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.