4

I am using composer for the first time so if I shouldn't be posting here I am very sorry.

I am following a youtube tutorial on the paypal api I have installed composer and created the json file the same as the example. composer.json is saved in the root folder for the website. the structure is below. composer diagnose composer.json: fail and property name is required.

{
"require": {
    "paypal/rest-api-php": "1.5.1"
}

}

user1633322
  • 83
  • 1
  • 7

2 Answers2

4

looks like your composer had much fresher version, check composer --version !

need to update composer.json with:

{
"name": "some/name",
"description": "Some description will be useful too!",

"require": {
    "paypal/rest-api-php": "1.5.1"
}
}

or install some old version, by exec 3lines

php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
sudo php composer-setup.php --install-dir=/usr/local/bin --filename=composer  --version=1.0.1
php -r "unlink('composer-setup.php');"
Vladimir Ch
  • 487
  • 1
  • 12
  • 26
2

The best way to start a project using Composer:

composer init

This will ask you some questions, some of them with sensible defaults that you can simply accept - others (like the name of your project) cannot be guessed.

The best way to install a package after that

composer require package/name

Optionally for development packages:

composer require --dev package/name

The composer command used here assumes you have downloaded "composer.phar" and renamed or symlinked it in a way that it can be called just by typing composer. Otherwise, replace that command with the one that works for you, like php composer.phar or composer.phar.

Sven
  • 69,403
  • 10
  • 107
  • 109