Comparison of popular application-level package management systems. In my presentation, I will describe basic assumptions of both systems, and how to use them.
to keep all dependencies together. Prepared to standarize way of project building and clarify definition what project consists of. Written to make developers life a bit easier. Composer vs Maven
desiginig: Making the build process easy Providing a uniform build system Providing quality project information Providing guidelines for best practices development Allowing transparent migration to new features Composer vs Maven
necessary information is available compile: compile the source code of the project test: test the compiled source code using a suitable unit testing framework. These tests should not require the code be packaged or deployed package: take the compiled code and package it in its distributable format, such as a JAR. integration-test: process and deploy the package if necessary into an environment where integration tests can be run verify: run any checks to verify the package is valid and meets quality criteria install: install the package into the local repository, for use as a dependency in other projects locally deploy: done in an integration or release environment, copies the final package to the remote repository for sharing with other developers and projects. clean: cleans up artifacts created by prior builds site: generates site documentation for this project Composer vs Maven
It allows you to declare the dependent libraries your project needs and it will install them in your project for you. Composer was designed to solve several typical issues: You have a project that depends on a number of libraries. Some of those libraries depend on other libraries. You declare the things you depend on. Composer finds out which versions of which packages need to be installed, and installs them (meaning it downloads them into your project). Composer vs Maven
command: curl -sS https://getcomposer.org/installer | php This is a standalone php script, nothing is needed else to be installed, it will also keep itself up to date (will notify if requires update). Composer vs Maven
this file describes the dependencies of your project and may contain other metadata as well. Most common key in composer.json file is „require” used to describe dependencies: { "require": { "monolog/monolog": "1.0.*" } } Composer vs Maven
>=1.0,<1.1 | >=1.2 Wildcard 1.0.* Next Significant Release ~1.2 equivalent to >=1.2,<2.0 Composer prefers stable releases by default, however it can be overwritten: 1.0.*@dev It is a valid version number – composer will also look for dev packages. Composer vs Maven
information in composer.json file, all needed to be done is executing single command: $ php composer.phar install Which will install all dependencies to „vendor” directory, and create composer.lock file. Composer vs Maven
the exact versions it installed, into a composer.lock file. This locks the project to those specific versions. Lock file should be added to repository – when „install” command is executed, composer first looks for lock file, if found, it will install exectly same versions of each library, this will ensure same libraries on every environment as developer designed. Composer vs Maven
exactly on desired version. When newer version of any library was published we should execute php composer.phar update command, which will download newest versions of libraries according to composer.json file, and update lock file. Also specific library can by updated – is we want to update only specific package we should execute: php composer.phar update package_name Composer vs Maven
packagist.org site, if any package other than posted on that site is needed, we can specify other repositiories to be checked for packages: "repositories": [ { "type": "vcs", "url": "https://github.com/Seldaek/monolog" }, { "type": "package", "package": { "name": "smarty/smarty", "version": "3.1.7", "dist": { "url": "http://www.smarty.net/files/Smarty-3.1.7.zip", "type": "zip" }, "source": { "url": "http://smarty-php.googlecode.com/svn/", "type": "svn", "reference": "tags/Smarty_3_1_7/distribution/" } ... Composer vs Maven
continuous integration tools like Jenkins or Hudson which will automatically build our project on different environments. Usage of composer or maven will ensure that we will have project built in exectly same way on every environment, and with same dependency package set. Composer vs Maven