삽질/개발,엔지니어링

composer 설치 및 사용

maengis 2021. 12. 29. 23:08

개인적으로 만들어 사용 중인 프레임워크에 엑셀 파일을 읽는 기능을 넣어야 해서 PhpSpreadsheet(https://github.com/PHPOffice/PhpSpreadsheet)를 쓰려다보니 겸사겸사 composer까지 설치하게 됐다.

 

# curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin/
All settings correct for using Composer
Downloading...

Composer (version 2.2.2) successfully installed to: /usr/local/bin/composer.phar
Use it: php /usr/local/bin/composer.phar

# composer.phar --version
Do not run Composer as root/super user! See https://getcomposer.org/root for details
Continue as root/super user [yes]? yes
Composer version 2.2.2 2021-12-29 14:15:27

 

로컬 개발환경에서 사용할 거라서 굳이 따로 링크는 안 걸었다.

이제 필요한 걸 설치하려고 하는데 오류가 뿜.

 

# composer.phar require PHPOffice/PhpSpreadsheet
Do not run Composer as root/super user! See https://getcomposer.org/root for details
Continue as root/super user [yes]? yes
Using version ^1.19 for phpoffice/phpspreadsheet
./composer.json has been created
Running composer update phpoffice/phpspreadsheet
Loading composer repositories with package information
Updating dependencies
Lock file operations: 11 installs, 0 updates, 0 removals
  - Locking ezyang/htmlpurifier (v4.14.0)
  - Locking maennchen/zipstream-php (2.1.0)
  - Locking markbaker/complex (3.0.1)
  - Locking markbaker/matrix (3.0.0)
  - Locking myclabs/php-enum (1.7.7)
  - Locking phpoffice/phpspreadsheet (1.19.0)
  - Locking psr/http-client (1.0.1)
  - Locking psr/http-factory (1.0.1)
  - Locking psr/http-message (1.0.1)
  - Locking psr/simple-cache (1.0.1)
  - Locking symfony/polyfill-mbstring (v1.23.1)
Writing lock file
Installing dependencies from lock file (including require-dev)
Package operations: 11 installs, 0 updates, 0 removals
  - Downloading myclabs/php-enum (1.7.7)
  - Downloading psr/simple-cache (1.0.1)
  - Downloading psr/http-message (1.0.1)
  - Downloading psr/http-factory (1.0.1)
  - Downloading psr/http-client (1.0.1)
  - Downloading markbaker/matrix (3.0.0)
  - Downloading markbaker/complex (3.0.1)
  - Downloading symfony/polyfill-mbstring (v1.23.1)
  - Downloading maennchen/zipstream-php (2.1.0)
  - Downloading ezyang/htmlpurifier (v4.14.0)
  - Downloading phpoffice/phpspreadsheet (1.19.0)
  - Installing myclabs/php-enum (1.7.7): Extracting archive
  - Installing psr/simple-cache (1.0.1): Extracting archive
  - Installing psr/http-message (1.0.1): Extracting archive
  - Installing psr/http-factory (1.0.1): Extracting archive
  - Installing psr/http-client (1.0.1): Extracting archive
  - Installing markbaker/matrix (3.0.0): Extracting archive
  - Installing markbaker/complex (3.0.1): Extracting archive
  - Installing symfony/polyfill-mbstring (v1.23.1): Extracting archive
  - Installing maennchen/zipstream-php (2.1.0): Extracting archive
  - Installing ezyang/htmlpurifier (v4.14.0): Extracting archive
  - Installing phpoffice/phpspreadsheet (1.19.0): Extracting archive
4 package suggestions were added by new dependencies, use `composer suggest` to see details.
Generating autoload files
3 packages you are using are looking for funding.
Use the `composer fund` command to find out more!

 

다 받아지면 vendor 디렉토리가 있는데, 사용하려는 소스에

 

require '받아진경로/vendor/autoload.php';

 

오토로드를 추가해주면 된다.

반응형