Laravel의 서비스 프로바이더 등록에 대해서 정리한다. 프로바이더 생성 명령어 php artisan make:provider SampleServiceProvider app/Provider 폴더에 생성됨 SampleServiceProvider 클래스의 register() 함수에 app()->bind() 함수를 이용하여 등록 ※ app()-bind에 대한 설명은 서비스 컨테이너 등록을 참조 class SampleServiceProvider extends ServiceProvider { /** * Register services. * * @return void */ public function register() { app()->bind('serviceProviderTest', function() { re..
간략하게 Laravel의 라이프 사이클을 정리해 둔다. WEB서버가 public/index.php 로 리다이렉트 1. autoload 로딩 (require없이 별도 파일의 클래스 이용가능) 2. Application 인스턴스작성(서비스 컨테이너) 3. HttpKernel 인스턴스작성 4. Request 인스턴스작성 5. HttpKernel 가 Request를 처리해서 Response 취득 6. Response 송신 7. terminate() 로 나머지 정리
Laravel의 서비스 컨테이너 등록에 대해서 정리한다. Laravel의 서비스 컨테이너 $app 에 대해서 bootstrap/app.php 에서 변수값을 담고 있다. $app = new Illuminate\Foundation\Application( $_ENV['APP_BASE_PATH'] ?? dirname(__DIR__) ); 기본적인 사용 방법에 대해서 등록의 경우 app()->bind() 불러올경우 app()->make() public function showServiceContainerTest() { // register app()->bind('lifeCycleTest', function() { return 'life cycle test'; }); // call $test = app()->mak..
의존성 주입에 대한 설명이 여러가지 있는데, 코드의 예가 한가지 있어 기록해 둔다. 리포지트로는 서비스클래스의 인수로서 주입받는 설계로 만든다. NG class Service: ~~ 생략 repository = TaskRepositoryMysql() ~~ 생략 서비스 내에서 리포지토리를 불러내면 1개의 리포지토리니 의존한 클래스가 되버림 OK class Service: def __init__(self, repository): self.repository = repository ~~ 생략 service = Service(TaskRepositroyMysql) service.save(task) 외부에서 인수로서 리포지토리를 받으면 서비스 클래스 이용시에 리포지토리가 지정되기 때문에 의존성이 없어짐
- Total
- Today
- Yesterday
- git branch 날짜순
- vue.js의 computed 속성
- 상류공정
- Laravel Pagination
- Laravel 라이프 사이클
- Laravel의 쿼리빌더와 Eloquent의 차이
- PHP의 Null
- PHP int 0값
- Laravel 페이지네이션
- Laravel 인증 라이브러리
- Laravel 데이터 취급 비교
- Laravel post등록
- php trait
- DATE DATETIME TIMESTAMP 차이점
- Laravel vite webpack
- PHP 7 8변경점
- Laravel 설정
- artisan serve란
- git branch 정렬
- Laravel 컴포넌트 참조
- Laravel 데이터 삭제 처리
- Laravel 이미지 폴더
- 생소한 일본어
- Laravel vaildation
- Laravel seeder 데이터
- TCP
- Laravel artisan 명령어 정리
- Laravel 서비스 프로바이더
- Laravel Carbon
- Laravel 서비스 컨테이너
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 | 29 |
30 | 31 |