Автор оригинала: David Wong.
1. Инсталляция композитора
2. Composer устанавливает пакеты сторонних производителей
1. Установка из командной строки:
composer require "curl/curl"
2. Редактирование установки файла composer.json:
{
"name": "test/test",
"description": "",
"license": "MIT",
"authors": [
{
"name": "a",
"email": "[email protected]"
}
],
"require": {
"php": ">=7.2.0",
"Curl/curl": "^1.6"// This is the package that needs to be installed
}
"config": {
//No.git folder
"preferred-install": "dist"
}
}Выполните установку/обновление composer
3. Создайте свой собственный установочный пакет composer
1. создайте пакеты
Я создал адрес проекта на github/gitlab: https://github.com/test/test Имя проекта должно быть определено в файле compoesr.json, который содержит следующие сведения:
{
// Note that the name defined here is the same as the name used later in require, not the suffix of GitHub URL
"name": "test1/test1",
"authors": [
{
"name": "a",
"email": "[email protected]"
}
],
"config": {
"preferred-install": "dist",
"sort-packages": true,
"optimize-autoloader": true,
"secure-http": false
}
}2. потребуйте пакет
Создайте файл composer.json в проекте, в котором необходимо использовать пакет, следующим образом:
{
"name": "aaa/bbb",
"authors": [
{
"name": "a",
"email": "[email protected]"
}
],
"require": {
"test1/test1": "dev-master"
},
"repositories": [
{
"type": "vcs",
// This address fills in the connecting address of the project.
"url": "https://github.com/test/test"
}
],
"config": {
"preferred-install": "dist",
"sort-packages": true,
"optimize-autoloader": true,
"secure-http": false
}
}3. Установите пакет
You can install your own package by executing `composer install', instead of installing it from packagist
4. Создайте свой собственный склад композиторов
Reference: https://github.com/composer/satis
5. Разница между установкой и обновлением
Both packages can be installed with the following distinctions: The `install'reads the composer. lock file and installs it according to the specified version of the cache. If not, it will be created after the installation. `update'does not read the composer. lock file, but upgrades a package or all packages and updates the composer. lock file Therefore, `composer Install'is recommended for production environments.
Оригинал: “https://developpaper.com/composer-simple-tutorial/”