Get the App
SLTechnology News&Howtos  ›  Servers  › 

How to install php dependency package with docker's composer

Shulou Source: shulou.com Published: 2022-06-01 11:55:29 09月26日 Update

This article introduces the relevant knowledge of "how to install the php dependency package with docker's composer". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

When composer is not installed on the machine, you can run it with docker: docker run

How can you run it in any directory? bash can define function:

Create a directory on the host to hold the configuration and cache files for composer:

Mkdir ~ / dnmp/composer

Open the host ~ / .bashrc or ~ / .zshrc file, and add:

Composer () {

Tty=

Tty-s & & tty=--tty

Docker run\

$tty\

-- interactive\

-- rm\

-- user $(id-u): $(id-g)\

-volume ~ / dnmp/composer:/tmp\

-- volume / etc/passwd:/etc/passwd:ro\

-- volume / etc/group:/etc/group:ro\

-volume $(pwd): / app\

Composer "$@"

}

Make the file work:

Source / .bashrc

Composer can be used in any directory on the host:

Cd ~ / dnmp/www/

Composer create-project yeszao/fastphp project-no-dev

(optional) if prompted for dependency, turn off dependency detection with-- ignore-platform-reqs-- no-scripts.

(optional) the first time you use composer, a config.json file is generated in the ~ / dnmp/composer directory, in which you can specify a domestic warehouse, for example:

{

"config": {}

"repositories": {

"packagist": {

"type": "composer"

"url": "https://packagist.laravel-china.org""

}

}

}

This is the end of "how to install the php dependency package with docker's composer". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Tags: Files directories hosts content more knowledge operation practicality learning next middle finger warehouse dilemma reality situation article time machine case for Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Microsoft MariaDB Shulou Information macOS OPPO Reno