PHP composer - jak inicializovat composer.json [1]
Composer - jak inicializovat composer.json ve vlastním projektu?
Přejdeme do našeho projektu a dáme:
composer init
Do not run Composer as root/super user! See https://getcomposer.org/root for details
Welcome to the Composer config generator
This command will guide you through creating your composer.json config.
Package name (<vendor>/<name>) [root/share]: up4cz/project
Description []: Lorem ipsum
Author [, n to skip]: Hanz
Minimum Stability []: beta
Package Type (e.g. library, project, metapackage, composer-plugin) []: project
License []: MIT
Define your dependencies.
Would you like to define your dependencies (require) interactively [yes]?
Search for a package:
Would you like to define your dev dependencies (require-dev) interactively [yes]? n
Add PSR-4 autoload mapping? Maps namespace "Up4cz\Project" to the entered relative path. [src/, n to skip]: n
Výsledný composer.json pak vypadá:
{
"name": "up4cz/project",
"description": "quick share util for big files",
"type": "project",
"license": "MIT",
"authors": [
{
"name": "Hanz"
}
],
"minimum-stability": "beta",
"require": {}
}
Pak už můžeme instalovat composer balíčky, třeba phpunit:
composer req phpunit/phpunit --dev
Příště se podíváme na PSR-4 auloloader pomocí composeru.