CI4
ci 사용자 라이브러리
수수깡깡
2022. 7. 7. 08:45
728x90
반응형
# 라이브러리
1. 장점
- 최소한의 리소스만 로딩
- 코드의 재활용 가능
- 코드분리
- 코드 단순화
2. 라이브러리 생성
App/Libraries 폴더에 라이브러리 파일 생성
ex) TestLib.php
<?php
namespace App\Libraries;
class TestLib
{
public function sample()
{
//
}
}
3. 라이브러리 사용
Controller에 use App\Libraries\{라이브러리} 명시한 후, new 라이브러리Class() 인스턴스 생성 후 사용
ex) TestController.php
namespace App\Controllers;
use App\Libraries\TestLib;
class TestController extends BaseController
{
public function index()
{
$this->testLib = new TestLib();
$this->testLib->sample();
}
}
728x90
반응형