php

    laravel - Failed to open stream: No such file or directory in /path/artisan on line 18 에러

    1. 에러 발생 깃헙에서 라라벨 프로젝트를 clone 후 서버 실행 시 위 Failed to open stream: No such file or directory in /path/artisan on line 18 에러가 발생했다. 2. 해결 방법 컴포저 패키지를 설치하지 않아서 발생한 오류였다. # 컴포저 패키지 설치 명령어 composer i

    laravel - 라라벨 8 + tailwindcss + git 설치 및 프로젝트 시작하기

    PHP 8.3 버전 설치 (mac os 기준) 1. 설치 brew install php@8.3 2. 정상 설치 확인 php -v 라라벨 8 버전 프로젝트 생성 (composer 사용) 1. 프로젝트 생성 composer create-project --prefer-dist laravel/laravel:^8 my-laravel-project 2. 서버 실행 cd my-laravel-project php artisan serve 3. 정상 설치 확인 http://127.0.0.1:8000/ tailwind css 설치(Laravel Mix 방식) 1. 설치 cd my-laravel-project npm install -D tailwindcss postcss autoprefixer npx tailwindcss ..

    yii - 객체를 HTMl 형식의 문자열로 출력하는 함수

    코드 /** * 객체를 HTML 형식의 문자열로 출력하는 함수 * @param object $obj 출력할 오브젝트 객체 * @param int $depth 출력할 데이터 깊이 * @return string HTML 형식으로 출력된 문자열 */ function dumpObject($obj, $depth = 999) { Yii::import('system.utils.CVarDumper'); echo CVarDumper::dumpAsString($obj, $depth, true); exit; } 예시 // 출력할 객체 생성 $obj = array( 'test1' => 'test1', 'test2' => 'test2', 'test3..

    php - 이미지 저장 함수

    코드 /** * 입력 이미지를 저장 후 출력 경로를 반환하는 함수 * @param string $img base64 인코딩 된 이미지 * @return string 출력 경로 */ function save_img($img) { // 이미지 저장 경로 $tempPath = '/경로/'; // 이미지 출력 시 경로 $tempURL = '/경로/'; // 이미지 저장 경로에 디렉토리가 존재하지 않는다면 생성 if (!is_dir($tempPath)) { mkdir($tempPath, TRUE); chmod($tempPath, 0755); } $explodArray = explode("base64,", $img); $img = $explodArray[1]; $img = str_rep..

    php - 날짜 연산

    코드 // 시간 연산 $연산후날짜 = date('Y-m-d', strtotime('연산 날짜', strtotime($날짜))); 예시 // 현재로부터의 시간은 다음과 같이 연산 가능 $ago_from_now = date('Y-m-d', strtotime('연산 날짜')); // 예) 2022-04-21 12:00:00 보다 4달 뒤 $four_month_ago_from = date('Y-m-d', strtotime('+4 months', strtotime(date('Y-m-d', strtotime('2022-04-21 12:00:00'))))); debug($four_month_ago_fro..

    php - 배열 순서 뒤집기

    코드 // 배열 순서 뒤집기 $배열 = array_reverse($배열); 사용 예시 $배열 = [0, 1, 2, 3, 4, 5]; $뒤집힌배열 = array_reverse($배열); debug($뒤집힌배열); // 결과 (5, 4, 3, 2, 1, 0)

    php - 문자열 문자 포함 여부

    코드 // 문자열 문자 포함 여부 체크 strpos($문자열, '찾을 문자');

    php - object value 값으로 배열 만들기

    코드 // 오브젝트 value 값으로 배열 만들기 $배열 = array_column($오브젝트, '키');