0% found this document useful (0 votes)
488 views4 pages

Composer Cheat Sheet

Composer is a dependency manager for PHP that allows developers to declare and install dependencies for PHP projects. The document provides a one-line installer for Composer, lists the most common Composer commands for installing, updating, and optimizing dependencies, and outlines the structure and keys that can be included in a composer.json file to configure a project's dependencies.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
488 views4 pages

Composer Cheat Sheet

Composer is a dependency manager for PHP that allows developers to declare and install dependencies for PHP projects. The document provides a one-line installer for Composer, lists the most common Composer commands for installing, updating, and optimizing dependencies, and outlines the structure and keys that can be included in a composer.json file to configure a project's dependencies.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

ComposerCheatSheetfordevelopers

ComposeristhedependencymanagerforPHPandyouareonaonepageonlydocumentationforthistool.
Officialdocumentationisontheofficialwebsite,thispagejustbringsyoutheessential.
Onelineinstaller
curlsShttps://getcomposer.org/installer|php

composer.pharmostneededcommandline
$phpcomposer.pharrequirevendorname/packagename
$phpcomposer.pharinstall
$phpcomposer.pharupdate
$phpcomposer.pharupdatelock
$phpcomposer.phardumpautoloadoptimize

othercommands
$phpcomposer.pharabout
$phpcomposer.phararchive
$phpcomposer.pharbrowse
$phpcomposer.pharclearcache
$phpcomposer.pharconfiglist
$phpcomposer.pharcreateprojectsymfony/standardeditiondir/
$phpcomposer.phardependsvendorname/packagename
$phpcomposer.phardiagnose
$phpcomposer.pharglobal
$phpcomposer.pharhelp
$phpcomposer.pharinit
$phpcomposer.pharlicenses
$phpcomposer.pharlist
$phpcomposer.pharremove
$phpcomposer.pharrunscript
$phpcomposer.pharsearchmykeywords
$phpcomposer.pharselfupdate
$phpcomposer.pharshow
$phpcomposer.pharsuggest
$phpcomposer.pharstatus
$phpcomposer.pharvalidate

composer.jsonfile
{
"name":"vendorname/projectname",
"description":"Thisisaverycoolpackage!",
"version":"0.3.0",
"type":"library",
"keywords":["logging","cool","awesome"],
"homepage":"http://jolicode.com",
"time":"20121221",
"license":"MIT",
"authors":[
{
"name":"XavierLacot",
"email":"[email protected]",
"homepage":"http://www.lacot.org",
"role":"Developer"
},
{
"name":"BenjaminClay",
"email":"[email protected]",
"homepage":"https://github.com/ternel",
"role":"Developer"
}
],
"support":{
"email":"[email protected]",
"issues":"https://github.com/jolicode/jane/issues",
"forum":"http://www.myforum.com/",
"wiki":"http://www.mywiki.com/",
"irc":"irc://irc.freenode.org/composer",
"source":"https://github.com/jolicode/jane",

require
Addsrequiredpackagestoyourcomposer.json
andinstallsthem.
The

require

composer.json

commandaddsnewpackagestothe
filefromthecurrentdirectory.

Afteradding/changingtherequirements,the
modifiedrequirementswillbeinstalledorupdated.

"docs":"https://github.com/jolicode/jane/wiki"
},
"require":{
"monolog/monolog":"1.0.*",
"joli/ternel":"@dev",
"joli/ternelbundle":"@stable",
"joli/semver":"^2.0",
"joli/package":">=1.0<1.1",
"acme/foo":"devmaster#2eb0c097"
},
"requiredev":{
"debug/devonly":"1.0.*"
},
"conflict":{
"anothervendor/conflict":"1.0.*"
},
"replace":{
"debug/devonly":"1.0.*"
},
"provide":{
"debug/devonly":"1.0.*"
},
"suggest":{
"jolicode/gifexceptionbundle":"Forfun!"
},
"autoload":{
"psr4":{
"Monolog\\":"src/",
"Vendor\\Namespace\\":""
},
"psr0":{
"Monolog":"src/",
"Vendor\\Namespace":["src/","lib/"],
"Pear_Style":"src/",
"":"src/"
},
"classmap":["src/","lib/","Something.php"],
"files":["src/MyLibrary/functions.php"]
},
"autoloaddev":{
"psr0":{
"MyPackage\\Tests":"test/"
}
},
"targetdir":"Symfony/Component/Yaml",
"minimumstability":"stable",
"repositories":[
{
"type":"composer",
"url":"http://packages.example.com"
},
{
"type":"vcs",
"url":"https://github.com/Seldaek/monolog"
},
{
"type":"pear",
"url":"http://pear2.php.net"
},
{
"type":"package",
"package":{
"name":"smarty/smarty",
"version":"3.1.7",
"dist":{
"url":"http://www.smarty.net/Smarty3.1.7.zip",
"type":"zip"
},
"source":{
"url":"http://smartyphp.googlecode.com/svn/",
"type":"svn",
"reference":"tags/Smarty_3_1_7/distribution/"
}
}
},
{

"type":"artifact",
"url":"path/to/directory/with/zips/"
},
{
"type":"path",
"url":"../../packages/mypackage"
}
],
"config":{
"processtimeout":300,
"useincludepath":false,
"preferredinstall":"auto",
"storeauths":"prompt",
"githubprotocols":["git","https","http"],
"githuboauth":{"github.com":"oauthtoken"},
"gitlaboauth":{"gitlab.com":"oauthtoken"},
"githubdomains":["entreprisegithub.me.com"],
"gitlabdomains":["entreprisegitlab.me.com"],
"githubexposehostname":true,
"disabletls":false,
"cafile":"/var/certif.ca",
"capath":"/var/",
"httpbasic":{"me.io":{"username":"foo","password":"bar"},
"platform":{"php":"5.4","extsomething":"4.0"},
"vendordir":"vendor",
"bindir":"bin",
"datadir":"/home/ternel/here",
"cachedir":"$home/cache",
"cachefilesdir":"$cachedir/files",
"cacherepodir":"$cachedir/repo",
"cachevcsdir":"$cachedir/vcs",
"cachefilesttl":15552000,
"cachefilesmaxsize":"300MiB",
"bincompat":"auto",
"prependautoloader":true,
"autoloadersuffix":"pony",
"optimizeautoloader":false,
"sortpackages":false,
"classmapauthoritative":false,
"notifyoninstall":true,
"discardchanges":false,
"archiveformat":"tar",
"archivedir":"."
},
"archive":{
"exclude":["/foo/bar","baz","/*.test","!/foo/bar/baz"]
},
"preferstable":true,
"scripts":{
"preinstallcmd":"MyVendor\\MyClass::doSomething",
"postinstallcmd":[
"MyVendor\\MyClass::warmCache",
"phpunitcapp/"
],
"preupdatecmd":"MyVendor\\MyClass::doSomething",
"postupdatecmd":"MyVendor\\MyClass::doSomething",
"prestatuscmd":"MyVendor\\MyClass::doSomething",
"poststatuscmd":"MyVendor\\MyClass::doSomething",
"prepackageinstall":"MyVendor\\MyClass::doSomething",
"postpackageinstall":[
"MyVendor\\MyClass::postPackageInstall"
],
"prepackageupdate":"MyVendor\\MyClass::doSomething",
"postpackageupdate":"MyVendor\\MyClass::doSomething",
"prepackageuninstall":"MyVendor\\MyClass::doSomething",
"postpackageuninstall":"MyVendor\\MyClass::doSomething",
"preautoloaddump":"MyVendor\\MyClass::doSomething",
"postautoloaddump":"MyVendor\\MyClass::doSomething",
"postrootpackageinstall":"MyVendor\\MyClass::doStuff",
"postcreateprojectcmd":"MyVendor\\MyClass::doThis",
"prearchivecmd":"MyVendor\\MyClass::doSomething",
"postarchivecmd":"MyVendor\\MyClass::doSomething",
},
"extra":{"key":"value"},
"bin":["./bin/toto"]
}

BroughttoyoubyJoliCodeInspiredbyNodejitsuFoundatypo?Somethingiswronginthisdocumentation?Justforkandeditit!

You might also like