Getting started with Composer on Ubuntu 14.04 / ~#root -i Getting started with Composer on Ubuntu 14.04 / ~#root -i Getting started with Composer on Ubuntu 14.04 / ~#root -i Getting started with Composer on Ubuntu 14.04 / ~#root -i Getting started with Composer on Ubuntu 14.04 / ~#root -i Getting started with Composer on Ubuntu 14.04 / ~#root -i Getting started with Composer on Ubuntu 14.04 / ~#root -i Getting started with Composer on Ubuntu 14.04 / ~#root -i
  • RU
  • UA
  • EN
  • Create an online store
  • Documentation
  • Blog
    • Unix ОS
    • Php
    • MySQL
    • JavaScript
    • Package Managers
    • Docker
    • Seo
  • Auxiliary services
    • Short Links
    • Exchange views YouTube
  • Sign in
  • Create Account
  • Home
  • Package Managers
  • Getting started with Composer on Ubuntu 14.04

Getting started with Composer on Ubuntu 14.04

Installing Composer globally on Ubuntu 14.04 is described here .

The first stage of familiarization will be offsite . In it you can read a lot of additional information that I did not submit in the articles.

The main source of plug-in libraries and ready-made solutions will be packagist.org . Finding the right ready-made solutions will depend on your ability to correctly enter information in the search bar.

composer.json :

composer.json - the main file in which the necessary libraries, the rules for their installation and other fine-tuning will be written.

Composer.json example :

{
"require": {
"php":">=7.0"
}
}

This example will check if our php version matches the one required in the file. Since I have php 5.6, it will give an error.

Problem 1
- This package requires php >=7.0 but your PHP version (5.6.36) does not satisfy that requirement.

composer.lock :

composer.lock - file of installable versions. When install is created if not created, but is not updated when re-installing. It stores the versions of the libraries used. To update versions, update is used.

Consider the basic commands to get started with composer:

1.Init- creates composer.json :

In the root of the site (for example /var/www/proj.loc), using the init command, you need to create a composer.json.

composer init

After entering init, you will be required to enter project data. Once input is complete, a composer.json file will be created.

Will create a file with standard information about the project, the user, but with an empty list of included libraries.

{
"name": "username/proj.loc",
"description": "Description",
"type": "proj.loc",
"license": "free",
"authors": [
{
"name": "username",
"email": "ad@min.loc"
}
],
"require": {}
}

2. Require - adding a new package from packegist.org to composer.json:

We are in the directory where the required composer.json is located (in my case /var/www/proj.loc).

composer require symfony/var-dumper

This command will pull symfony/var-dumper , its related packages in use, and do an install . This package will be deployed in the standard project directory in the vendor folder and regenerate the autoload.php file, which is responsible for including all installed libraries.

But there is also the ability to add the necessary packages manually, and do install or update.

Example:

{
"name": "username/proj.loc",
"description": "Description",
"type": "proj.loc",
"license": "free",
"authors": [
{
"name": "userbame",
"email": "ad@min.loc"
}
],
"require": {
"symfony/var-dumper": "^3.4"
}
}

3. Install - depending on the require block in composer.json , it installs all the packages specified in it, pulls the links used by these packages.

composer install

After that, a vendor folder is created near the composer.json file and packages are pulled into it. If composer.lock is not created, it will be created with the package versions at the time of installation. If you re-install, then composer.lock will not be regenerated, and the versions that are written in composer.lock will be pulled up

4. Update - updates the versions of the packages in the composer.lock file. Doesn't touch versions in composer.json.

composer update

Unlike install, it pulls up the latest versions of the required libraries and writes them into composer.lock, and the next install will take new versions from everyone if composer.lock is present (since it is in priority).

You should be careful with this command, as updates may be pulled up in which the methods you use are called differently and thus you can fail the assembly.

A complete list of commands can be found here .

31 May 18
658
0

Comments

Name
E-mail
Rating
Review

Other articles from the category

03 June 2018

Installing Propel in our project via Composer

Let's pull Propel2 ORM into our project using Composer. Let's take a look at the related packages needed for Propel2.

01 June 2018

Connecting Composer libraries to Php site

Having figured out what Compser is and what it is for, you should figure out how to use it on the site. In the article, we will consider connecting libraries pulled up through Composer.

Categories

  • Unix OS
  • Php
  • MySQL
  • JavaScript
  • Package Managers
  • Docker
  • Seo

Latest comments

Добрый день, Сергей. Я на более новых версиях блют...
root-i
23.02.23
Пробовал на transmart колонке. Ничего из перечисле...
Сергей
20.02.23
HenryMit, может быть
root-i
07.02.23
Неофрейдизм — это… Определение, принципы, представ...
HenryMit
07.02.23

I share information in which I needed help and spent a lot of time figuring it out. If the information helped at least one person, then this site was not created in vain.

Thank you for the continuation of the site:
Contacts

Telegram Viber Mail

Search for articles

  • Sign in
  • Create Account

Powered by chmod -R