Questions tagged [composer-php]

Composer is an application-level package manager for the PHP programming language. It provides a standard format for managing with ease PHP-based project dependencies (libraries) and was strongly inspired by Node.js's "npm" and Ruby's "bundler". Use with the [php] tag

Presentation

Composer is an application-level package manager.

Yes, it deals with "packages" or libraries, but it manages them on a per-project basis, installing them in a directory inside your project.

By default it will never install anything globally.

Thus, it is considered a PHP-based project package manager.

Useful links

  • Current documentation: The main source of documentation for the project.

  • Packagist: It is the main Composer repository.

    It aggregates all sorts of PHP packages that are installable with Composer.

  • The source code is available on GitHub and distributed under MIT license.

  • Composer as a service: copy/paste your composer.json and get the vendor.zip file of your dependencies.

    Also, you can check the log of your build; it could be useful for debug.

  • Packanalyst: Packanalyst is a service that lets you browse packages from Packagist and shows who is using and implementing your interfaces / abstract classes / traits.

10003 questions
563
votes
8 answers

Should composer.lock be committed to version control?

I'm a little confused with composer.lock used in an application with a repository. I saw many people saying that we should not .gitignore composer.lock from the repository. If I update my libraries in my dev environment, I will have a new…
Pierre de LESPINAY
  • 40,390
  • 50
  • 195
  • 282
492
votes
19 answers

How to remove a package from Laravel using composer?

What is the correct way to remove a package from Laravel using composer? So far I've tried: Remove declaration from composer.json (in "require" section) Remove any Class Aliases from app.php Remove any references to the package from my code :-) Run…
igaster
  • 10,005
  • 4
  • 21
  • 25
461
votes
9 answers

How to install a specific version of package using Composer?

I am trying to install a specific version of a package using Composer. I tried composer install and composer require but they are installing the latest version of the package. What if I want an older version?
gdaras
  • 7,021
  • 2
  • 20
  • 36
373
votes
8 answers

How to update a single library with Composer?

I need to install only 1 package for my SF2 distribution (DoctrineFixtures). When I run php composer.phar update I get - Updating twig/twig (dev-master 39d94fa => v1.13.0) The package has modified files: M CHANGELOG M…
Tool
  • 10,875
  • 15
  • 64
  • 116
307
votes
33 answers

Composer require runs out of memory. PHP Fatal error: Allowed memory size of 1610612736 bytes exhausted

I am trying to add HWIOAuthBundle to my project by running the below command. composer require hwi/oauth-bundle php-http/guzzle6-adapter php-http/httplug-bundle HWIOAuthBundle github: https://github.com/hwi/HWIOAuthBundle When I try to run composer…
Brian Chen
  • 3,161
  • 2
  • 7
  • 14
304
votes
13 answers

Laravel 5 - artisan seed [ReflectionException] Class SongsTableSeeder does not exist

When I run php artisan db:seed I am getting the following error: [ReflectionException] Class SongsTableSeeder does not exist What is going on? My DatabaseSeeder class:
Sasha
  • 7,725
  • 21
  • 78
  • 154
300
votes
8 answers

How to get list of all installed packages along with version in composer?

I have been working on a project using Symfony 2.1 on my local machine. I have uploaded it to my server but when I try and install the vendor bundles using Composer, I'm getting a lot of dependency errors. Presumably this is something to do with…
Dan
  • 5,311
  • 6
  • 34
  • 52
247
votes
3 answers

What's the difference between require and require-dev?

I'm new to the composer and I would like to know the difference between require and require-dev. The composer website doesn't offer a good explanation the difference between these two. The part that I don't get is Lists packages required for…
slier
  • 5,855
  • 5
  • 31
  • 51
238
votes
4 answers

How to remove unused dependencies from composer?

I installed a package with composer, and it installed many other packages as dependencies. Now I uninstalled the main package with composer remove packageauthor/packagename, but all the old dependencies were not removed. I expected composer to clean…
Lorenz Meyer
  • 17,418
  • 21
  • 68
  • 109
237
votes
5 answers

What Are the Differences Between PSR-0 and PSR-4?

Recently I've read about namespaces and how they are beneficial. I'm currently creating a project in Laravel and trying to move from class map autoloading to namespacing. However, I can't seem to grasp what the actual difference is between PSR-0 and…
Varun Nath
  • 5,230
  • 3
  • 21
  • 38
235
votes
7 answers

PHP7 : install ext-dom issue

I'm running laravel 5.4 on Ubuntu 16.04 server with PHP7. trying to install cviebrock/eloquent-sluggable package throw some error: pish@let:/home/sherk/ftp/www$ sudo composer require cviebrock/eloquent-sluggable Do not run Composer as root/super…
alex
  • 5,897
  • 7
  • 38
  • 66
234
votes
37 answers

Running Composer returns: "Could not open input file: composer.phar"

I am new to symfony2 and reading symblog. In third chapter while trying with data-fixtures I tried the command: php composer.phar update but I got the error: Could not open input file: composer.phar So I googled a little and tried php…
user3291745
  • 2,401
  • 2
  • 10
  • 8
210
votes
4 answers

Composer: how can I install another dependency without updating old ones?

I have a project with a few dependencies and I'd like to install another one, but I'd like to keep the others the way they are. So I've edited the composer.json, but if I run composer install, I get the following output: Installing dependencies from…
duality_
  • 15,454
  • 20
  • 74
  • 92
209
votes
15 answers

Composer install error - requires ext_curl when it's actually enabled

I'm trying to install Facebook PHP SDK with Composer. This is what I get $ composer install Loading composer repositories with package information Installing dependencies (including require-dev) Your requirements could not be resolved to an…
Michal Artazov
  • 3,698
  • 8
  • 23
  • 36
192
votes
5 answers

How to deploy correctly when using Composer's develop / production switch?

Composer has the option to load several dependencies only while being in development, so the tools will not be installed in production (on the live server). This is (in theory) very handy for scripts that only make sense in development, like tests,…
Sliq
  • 14,005
  • 24
  • 99
  • 137
1
2 3
99 100