CI 묻고 답하기

제목 CI 초보인데, 초기 실행 순서를 잘 모르겠습니다.
글쓴이 옹알이 작성시각 2013/08/16 23:14:56
댓글 : 1 추천 : 0 스크랩 : 0 조회수 : 19594   RSS
'만들면서 배우는 CodeIgniter 프레임워크'를 보고 공부하고 있는데, 
하다보니까 처음 실행순서가
http://localhost를 실행하면,
application/config/routes.php에 $route['default_controller'] = "main";으로 되어 있을 경우

1) application/controller/main.php
여기서 호출에 따라
2) application/model/todo_m.php(Model) 이나 application/view/todo_v.php(view)가 실행이 되는 걸로 알고 있었습니다.

근데 책을 좀 더 진행하니 갑자기 주소가 어느새
http://localhost/todo/index.php/main/view/1로 바뀌어 있네요.
todo는 폴더명, main은 main.php(Controller), view는 view()를 의미하는 건 알겠는데,
index.php의 정체는 무엇인가요?


그리고 index.php를 주소에서 없앨 때, '서버 디렉토리'의 AllowOverride라고 하였는데,
서버 파일이 있는 주소가 있는 여기가 맞나요?

DocumentRoot "C:/xampp/htdocs"
<Directory "C:/xampp/htdocs">
    #
    # Possible values for the Options directive are "None", "All",
    # or any combination of:
    #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
    #
    # Note that "MultiViews" must be named *explicitly* --- "Options All"
    # doesn't give it to you.
    #
    # The Options directive is both complicated and important.  Please see
    # for more information.
    #
    Options Indexes FollowSymLinks Includes ExecCGI
 
    #
    # AllowOverride controls what directives may be placed in .htaccess files.
    # It can be "All", "None", or any combination of the keywords:
    #   AllowOverride FileInfo AuthConfig Limit
    #
    AllowOverride All
 
    #
    # Controls who can get stuff from this server.
    #
    Require all granted
</Directory>


 다음글 ajax 페이징 (10)
 이전글 class 내부에서 class 이름을 얻는 방법이 있을... (2)

댓글

변종원(웅파) / 2013/08/17 11:28:58 / 추천 0
localhost로 접속하면 routes.php 의 default controller에 의해

localhost/index.php/main/index 가 실행이 됩니다.

main 컨트롤러이고, index()함수는 함수명을 지정하지 않았을때 자동실행되는 함수입니다.

그리고 index.php는 프레임워크의 시작점입니다. 이 파일을 통해 프레임워크의 모든
내부 파일을 사용하고 주소를 해석하고 하는 것이 가능해집니다.

책에도 나오지만 중요한  파일인데 주소에서는 무의미하게 반복이 되기 때문에
index.php를 없애고 쓰는겁니다.

세번째 질문도 그 위치가 맞습니다. (만약 vhost를 설정했다면 그쪽도 바꿔줘야 합니다.)