composer : php 소프트웨어와 필요 라이브러리의 의존성을 관리하기 위한 표준 포맷을 제공하는 php 프로그래밍 언어의 패키지 관리자
php 버전에 따라 지원 가능한 라라벨 프로젝트 버전 다르다.
라라벨 홈페이지에서 제공하는 curl 을 통한 설치 방법은 가장 최신의 라라벨 버전을 지원하기 한다.
curl -s "https://laravel.build/example-app" | bash
라라벨 최신 버전이 아니라 특정 버전의 라라벨을 설치하고 싶은 경우 현재 설치한 php가 해당 버전의 라라벨을 지원하는 지 확인해야 한다.
라라벨 5.8 버전을 설치하고 싶은 경우 php 7.1 을 설치해야 한다.
특정 버전의 php 설치 방법 및 php 버전 변경
composer도 지원가능한 php 버전이 별도로 존재하므로 composer 버전 변경이 필요할 수 있다.
composer 와 php 버전은 상호영향을 주고받으므로 composer 변경을 할 때 php 버전을 변경해야할 수 있다.
# 특정 버전의 php 설치
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get install php7.1
# php 버전 변경
sudo update-alternatives --config php
composer self-update --2.2
특정 버전의 프로젝트 설치 방법
composer create-project laravel/laravel <project_name> "5.8.*" --prefer-dist
아래와 같은 오류가 출력되면서 프로젝트 생성에 실패하는 경우 그 아래의 명령어 입력
php 버전에 맞는 php.xml을 설치해주어야 한다.
Problem 1
- phpunit/phpunit[7.5.0, ..., 7.5.20] require ext-dom * -> it is missing from your system. Install or enable PHP's dom extension.
- Root composer.json requires phpunit/phpunit ^7.5 -> satisfiable by phpunit/phpunit[7.5.0, ..., 7.5.20].
sudo apt-get update
# 7.1 버전 php.xml 설치
sudo apt-get install php7.1-xml
# 최신버전 php.xml
sudo apt-get install php7.1-xml
Composer를 사용하여 Github에서 패키지를 설치하거나 업데이트 할 때, Github의 OAuth 토큰 설정
이 명령어는 Composer가 GitHub API에 접근할 때, 인증 문제를 해결하고 더 높은 API 사용 한도를 적용받으며, 프라이빗 저장소 접근 권한을 설정하기 위해 GitHub OAuth 토큰을 글로벌하게 설정하는 데 사용됩니다. 이를 통해 더 원활하게 패키지를 관리할 수 있게 됩니다. token 은 github > settings > developer settings > Personal access tokens > Tokens(classic) 에서 생성
github oauth 설정 안 하면 프로젝트 생성 시 패키지 다운로드 속도가 매우 느림
Cloning failed using an ssh key for authentication, enter your GitHub credentials to access private repos
When working with _public_ GitHub repositories only, head here to retrieve a token:
https://github.com/settings/tokens/new?scopes=&description=Composer+on+DESKTOP-S0C54IA+2024-06-09+1658
This token will have read-only permission for public information only.
When you need to access _private_ GitHub repositories as well, go to:
https://github.com/settings/tokens/new?scopes=repo&description=Composer+on+DESKTOP-S0C54IA+2024-06-09+1658
Note that such tokens have broad read/write permissions on your behalf, even if not needed by Composer.
Tokens will be stored in plain text in "/home/naviqp/.config/composer/auth.json" for future use by Composer.
For additional information, check https://getcomposer.org/doc/articles/authentication-for-private-packages.md#github-oauth
Token (hidden):
No token given, aborting.
You can also add it manually later by using "composer config --global --auth github-oauth.github.com <token>"
Failed to download sebastian/code-unit-reverse-lookup from dist: curl error 28 while downloading https://api.github.com/repos/sebastianbergmann/code-unit-reverse-lookup/zipball/ac91f01ccec49fb77bdc6fd1e548bc70f7faa3e5: Resolving timed out after 1698660 milliseconds
Now trying to download from source
composer config --global --auth github-oauth.github.com <token>
docker-compose Commands 관련 sail 명령어 실행 시 아래와 같이 출력하는 경우 그 아래 명령어 실행
프로젝트 root 위치에 docker-compose 파일이 존재하지 않아 발생하는 이슈
명령어를 실행하면 선택 옵션이 제공
필요에 따라 웹서버, 데이터베이스, 기타 서비스들을 선택
no configuration file provided: not found
no configuration file provided: not found
# sail 초기화 및 docker 설정 파일 생성
php artisan sail:install