기본 콘텐츠로 건너뛰기

CodeIgniter 활용 팁 정리

CodeIgniter 활용 팁 정리

"만들면서 배우는 CodeIgniter" (변종원 지음 / 한빛미디어)를 읽고, 도움이 될만한 활용 팁을 정리해 나간다. 인터넷에서 찾은 정보를 함께 정리한다.

개요

>> "PHP 창시자인 라스무스(Rasmus)는 '프레임워크는 쓰지 말라"고 말했다.

프레임워크를 사용하면 순수한 PHP보다 성능이 떨어지기 때문인데, 그래도 쓰려면 CodeIgniter를 사용하라는 내용으로 라스무스가 DrupalCon 2008에서 "Simple is Hard"라는 내용으로 발표하였다. 여타의 프레임워크와는 달리, 응답속도와 초당 트랜잭션이 현저하게 높은 것을 확인할 수 있다.

>> 다른 프레임워크는 테이블을 기반으로 모델, 컨트롤러, 뷰에 해당하는 코드를 자동으로 생성하는 방식을 택하며, 하나의 기능을 구현하기 위해서는 테이블/모델/컨트롤러/뷰를 모두 만들어야 하는 제약사항이 있는 경우가 많다. 반면 CodeIgniter는 각 레이어 사이의 결합이 느슨하게 유지되므로, 컨트롤러/뷰만 만들어도 기능이 동작하는 방식을 취했다.

>> Clean URL(간편 URL) 포맷을 지향한다. 또는 RESTful URL, SEO(Search Engine Optimization) 친화적 URL을 지향한다.

CodeIgniter 개발환경 구성하기

캐릭터셋>> CodeIgniter의 모든 파일은 UTF-8을 사용한다. euc-kr을 사용하는 경우 한글이 깨진다.

라이브러리>> output 라이브러리는 자동으로 로드된다. 예를 들어 {elased_time}은 현재 페이지의 실행시간을, {memory_usage}는 페이지의 메모리 사용량을 표시한다.

서버 설정하기

>> CodeIgniter에서 index.php 파일이 Front Controller의 역할을 담당한다. 따라서 URL 호출시 아래와 같이 index.php가 위치해야 한다.

http://localhost/todo/index.php/main/lists

만약 아래와 같이 URL을 사용하고자 한다면,

http://localhost/todo/main/lists

아파치 서버 설정에서 rewrite_module을 로드하고, AllowOverride All로 설정한다. 그리고 CodeIgniter의 설정 파일인 config/config.php 파일에서 index_page 설정 값을 공백으로 바꾼다.

/*

|--------------------------------------------------------------------------

| Index File

|--------------------------------------------------------------------------

|

| Typically this will be your index.php file, unless you've renamed it to

| something else. If you are using mod_rewrite to remove the page set this

| variable so that it is blank.

|

*/

$config['index_page'] = '';

from http://socurites.tistory.com/302 by ccl(A)

댓글

이 블로그의 인기 게시물

[PHP] 코드이그니터 - 파일업로드 구현

[PHP] 코드이그니터 - 파일업로드 구현 파일 업로드 이번에 PHP 프레임워크인 코드 이그니터(Codeigniter)를 사용하여 홈페이지를 만드는데 사용한 이미지 업로드용 코드 입니다. upload 라이브러리를 사용하고 app~ 와 같은 위치에 upload 폴더를 만드고 다음 코드를 사용한다음 ajax 로 호출하여 파일을 업로드 합니다. function index() { // Upload 설정 $config['upload_path'] = './upload/'; $config[\'allowed_types\'] = 'gif|jpg|png'; $config['max_size'] = 100; // 100k $config['max_width'] = 1024; $config['max_height'] = 768; $this->load->library('upload', $config); $data = array(); if (! $this->upload->do_upload("service_image")) { $error = array('error' => $this->upload->display_errors()); } else { //$data = array('upload_data' => $this->upload->data()); $this->output->set_output("./upload/".$this->upload->data('file_name')); } } jquery 를 이용한 파일 업로드 호출 코드 function upload() { var datas, xhr; datas = new FormData(); datas.append( 'service_image', $( ...

2017년 1월 스타트업에서 구인할때 주로 원하는 개발 기술

2017년 1월 스타트업에서 구인할때 주로 원하는 개발 기술 php mysql linux android git kotlin gcm/fcm python mssql mongodb amazon aws ios objective-c swift github python c++ django python postgresql amazon aws html5/css3/javascript android java mysql python c++ c# java aws cloud-server dbms node.js postgresql redis nginx react.js hapi.js amazon aws restful-api angularJS jQuery html5/css3/javascript android firebase custom ui component restful-api asp.net c# html css javascript bootstrap angularjs node.js php mongodb redis 프론트엔드 주요 기술 javascript jquery ajax angularjs wbesocket html5/css3/javascript android ios java xcode node.js coffeescript mysql amazon ec2 amazon es3 android ios node.js php python java ios php mysql apache python android redis node.js jquery msa node.js java restful-api linux nosql golang redis nginx ...

이클립스 코드이그나이터 연동 ( eclipse codeigniter )

이클립스 코드이그나이터 연동 ( eclipse codeigniter ) https://ellislab.com/codeigniter/user-guide/installation/downloads.html 위의 사이트에서 코드이그나이터를 다운 받는다. 다운받은 압축 파일을 풀어 준다. 이클립스에서 php 프로젝트를 생성한 공간에 코드이그나이터 압축파일을 복사 붙여넣기 해준다. 위와 같은 화면이 나오면 정상적으로 연동이 된 것 입니다. from http://nahosung.tistory.com/22 by ccl(A) rewrite - 2020-03-06 16:20:55