A file is generated from the composer tool. Which is the main file of the whole project which we call the composer file. The extension file is composer.json. It is the main composer.json that defines your project requirements.
How to setup a new or existing package
You can also say how to create a composer.json file in a Project to make it a package.
- Ussing composer init Command
- Manually Creating composer.json file
Ussing composer init Command
composer init – It is used to set up a new or existing package. The init command creates a basic composer.json file in the current directory.
Every project is a package.
As soon as you a composer.json in a directory, that directory is a package.
composer.json
Package name – in order to make that package installable you need to give it a name. It consists of vendor name and project name, separated by/. The name can contain any character, including white spaces, names are case insensitive, the convention is all lowercase and dashes for word separation. It is required for published packages(libraries).
Syntax:- vendorname/packagename
Ex:- devopsschool/dev
Description- A short description of the package. Usually, this is one line long. It is required for published packages(libraries).
Authors – The authors of the package. This is an array of objects.
Each author object can have the following properties:
- name: The author’s name. Usually their real name.
- email: The author’s email aaddress.
- homepage: An URL to the author’s website.
- role: The author’s role in the prject (e.g. developer or translator)
Minimum Stability – Composer accepts these flags as minimum-stability settings. The defualt setting for minimun-stability if not provided is assumed to be stable, but you sould define any of the flags down the hierarchy.
- stable (most stable)
- re
- beta
- alpha
- dev (least stable)
Package Type – Package types are used for custom installation logic. If you have a package that needs some special logic, you can define a custom type. It default to library.
- Library
- Project
- Metaapackage
- Composer-plugin
License – The license of the package. This can be either a string or an array of strings.
Ex:- MIT
Tagged : command / composer / laravel / project / Tools