Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When creating a composer package, what "Package Type" should I choose

Tags:

I'm creating my first PHP Composer package (following these instructions). I've run

$ composer init 

and am filling in the details, it is now asking me for

Package Type (e.g. library, project, metapackage, composer-plugin) []:

I assume this is just a human-decipherable label for categorising the different packages?

I wondered if there is a definition of package types somewhere?

like image 483
kris Avatar asked Feb 08 '17 23:02

kris


People also ask

What are composer packages?

Composer is a dependency manager. It installs packages locally. A package is essentially a directory containing something. In this case it is PHP code, but in theory it could be anything. And it contains a package description which has a name and a version.

Where does composer install packages from?

Composer can be configured to install packages to a folder other than the default vendor folder by using composer/installers. Now when your theme is installed with Composer it will be placed into wp-content/themes/themename/ folder. Check the current supported types for your package.


1 Answers

I found this as posting the question :

Composer Package Types

Out of the box, Composer supports four types:

  • library: This is the default. It will simply copy the files to /vendor.

  • project: This denotes a project rather than a library. For example application shells like the Symfony standard edition, CMSs like the SilverStripe installer or full fledged applications distributed as packages.

  • metapackage: An empty package that contains requirements and will trigger their installation, but contains no files and will not write anything to the filesystem.

  • composer-plugin: A package of type composer-plugin may provide an installer for other packages that have a custom type. Only use a custom type if you need custom logic during installation.

Package types are used for custom installation logic. If you have a package that needs some special logic, you can define a custom type. This could be a symfony-bundle, a wordpress-plugin or a typo3-cms-extension. These types will all be specific to certain projects, and they will need to provide an installer capable of installing packages of that type.

Source : https://getcomposer.org/doc/04-schema.md

like image 95
kris Avatar answered Sep 19 '22 14:09

kris