Output 클래스 업그레이드
문서
변경된 사항
Output 클래스가 Response 클래스로 변경되었습니다.
메서드 이름이 변경되었습니다.
업그레이드 가이드
HTTP Response 클래스의 메서드 이름이 약간 다릅니다. 가장 중요한 이름 변경은 밑줄 메서드 이름에서 camelCase로의 전환입니다. 버전 3의
set_content_type()메서드는 이제setContentType()이 되는 식입니다.대부분의 경우
$this->output을$this->response로 변경한 후 메서드를 이어서 써야 합니다. 모든 메서드는 HTTP 응답에서 확인할 수 있습니다.
코드 예제
CodeIgniter 버전 3.x
<?php
$this->output->set_status_header(404);
// ...
$this->output
->set_content_type('application/json')
->set_output(json_encode(array('foo' => 'bar')));
CodeIgniter 버전 4.x
<?php
$this->response->setStatusCode(404);
// ...
return $this->response->setJSON(['foo' => 'bar']);