[CI] php.ini에서 error_reporting 설정을 해도 반영이 안되는 경우

[CI] php.ini에서 error_reporting 설정을 해도 반영이 안되는 경우

php.ini에서 아무리 error_reporting 값을 변경해도 CI에서는 반영이 되지 않습니다.

그 이유는 CI 자체에서 error_reporting 값을 상수로 잡고 있기 때문입니다.

아주 친절하게 설명이 되어있지만 저처럼 이 부분을 미리 숙지하지 못해 php.ini를 마구 수정하거나 아파치를 무한 restart하는 삽질을 하는 불상사가 없기를 바랍니다.

아래 파일은 CI의 최상위 루트에 존재하는 index.php 파일의 일부입니다. 파일을 열자마자 보이는 내용입니다.  이렇게 친절한 설명을 두고도 삽질을 하다니 ㅠㅠ

보시면 아시겠지만 ENVIRONMENT 라는 상수로 에러 출력 여부를 정의하고 있습니다. 기본값은 production이 아닌 development로 되어있습니다. 즉, E_ALL = “모든 에러와 경고를 보여주겠다” 로 되어있던 것이죠.

개발을 완료하고 릴리즈 할땐 production으로 상수 값을 변경해줍니다.

개발이나 디버깅 시에는 testing 으로 상수를 변경하시고 switch 문에서 에러 출력 범위를 정해주시면 됩니다.

/*
 *---------------------------------------------------------------
 * APPLICATION ENVIRONMENT
 *---------------------------------------------------------------
 *
 * You can load different configurations depending on your
 * current environment. Setting the environment also influences
 * things like logging and error reporting.
 *
 * This can be set to anything, but default usage is:
 *
 *     development
 *     testing
 *     production
 *
 * NOTE: If you change these, also change the error_reporting() code below
 *
 */
	define('ENVIRONMENT', 'production');
/*
 *---------------------------------------------------------------
 * ERROR REPORTING
 *---------------------------------------------------------------
 *
 * Different environments will require different levels of error reporting.
 * By default development will show errors but testing and live will hide them.
 */

if (defined('ENVIRONMENT'))
{
	switch (ENVIRONMENT)
	{
		case 'development':
			error_reporting(E_ALL);
		break;

		case 'testing':
		case 'production':
			error_reporting(0);
		break;

		default:
			exit('The application environment is not set correctly.');
	}
}

난 php.ini 설정대로 갔으면 한다! 하는 분은 뭐 저 부분을 날리셔도 되겠지만 프레임워크에서 정한 룰은 최대한 지켜가며 사용해야 한다는게 저의 생각입니다.

%d 블로거가 이것을 좋아합니다: