Laravel 에서 사용하는 유용한 Console 명령어

Laravel 에서 사용하는 유용한 Console 명령어 updated_at: 2024-07-16 12:17

Laravel 에서 사용하는 유용한 Console 명령어

라라벨 버전 확인

Laravel Framework Version 확인

php artisan --version

webpack

webpack.mix 적용
dev, prod의 차이점은 minimize 하느냐 안하느냐의 차이이다.

// 개발자 모드로 진행
npm run dev 
npm run development

// 상용서비스 모드로 진행
npm run prod
npm run production

config

config 파일이나 .env 를 cache 하거나 다시 풀어둔다.
cache 화 하면 원본파일을 수정하더라도 원본에서 보는 것이 아니라 캐시된 파일에서 호출하게 된다.
따라서 수정된 내용을 적용하기를 원하는 clear 후에 다시 cache하여야 한다.
이후 다른 옵션에서의 cache와 clear는 이것과 동일 한다.
config 변경시 https://laravel.com/docs/5.4/configuration clear는 cache를 없앤다 이경우 .env를 수정하면 즉각 반영된다. 하지만 laravel 속도가 떨어지므로 env가 종종 바뀔때에는 clear를 사용하지만 production 에서는 cache를 사용하는 것이 좋다.

php artisan config:cache 
php artisan config:clear

사이트 유지보수 (up / down)

php artisan down
php artisan up

Artisan List

artisan 명령으로 실행할 수 있는 모든 명령어 들이 출력된다.

php artisan list

publish

vendor에 있는 config / views 파일을 현재 config or views 폴더로 이동시킨다.

php artisan vendor:publish 

route

route:list

Route List를 출력한다. 라우터 및 맵핑된 Controller등을 조회하여 매치가 되지 않으면 에러를 발생시킨다.

php artisan route:list
php artisan route:clear

migrate

php artisan migrate:generate 
php artisan migrate:status
php artisan migrate

cache

모든 캐시를 삭제삭한다.

php artisan cache:clear

debugbar

디버거용 로깅파일들을 삭제시킨다. likely not necessary since it returned "No Debugbar Storage found.."

php artisan debugbar:clear

optimize

php artisan optimize

dump-autoload

class not found 일때 매우 좋음

composer dump-autoload -o

auto load files 재실행

composer dumpautoload

package

Package 설치

composer require [패키지명]
composer require --dev [패키지명]

Package 삭제

composer remove [패키지명]

key

.env의 APP_KEY 생성 (env 파일의 APP_KEY 자동 교체)

php artisan key:generate

storage

torage 폴더 link

php artisan storage:link

That creates a symlink from public/storage to storage/app/public for you and that's all there is to it. Now any file in /storage/app/public can be accessed via a link like:

http://somedomain.com/storage/image.jpg

참조 : https://laravel.com/docs/8.x/deployment note that if you still want the require-dev packages you can leave off the --no-dev option

composer install --optimize-autoloader --no-dev

에러시 아래 대로 하면 문제가 줄어듦

php artisan optimize:clear // 모든 optimize 된것을 클래어 후 아래처럼 필요한 것들을 cache화 함
php artisan config:cache
php artisan route:cache
php artisan view:cache

$ php artisan env

평점을 남겨주세요
평점 : 5.0
총 투표수 : 1

질문 및 답글