2015-04-24 13:33



Ive downloaded a helper library of an API written in PHP from GITHUB, but when I download the .zip file it doesnt contain vendor folder, but everywhere in the code it is seeking some files from vendor folder-which is error in running.

Can you help me how to get these? new to the system.

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答


  • dongluan1743 dongluan1743 6年前

    If you're working with PHP and you can't find a vendor/ directory that you expect to see, that PHP codebase probably uses Composer:

    Composer is a tool for dependency management in PHP. It allows you to declare the dependent libraries your project needs and it will install them in your project for you.

    One surefire way to know that a project uses Composer (aside from reading its documentation) is to see if there are composer.json and composer.lock files (probably) in the root of the repository. These files define the project's dependencies.

    To generate the vendor/ directory,

    1. install Composer,
      • there are a few ways to do this, and it is OS-dependent, but something like curl -sS | php should work if you're on Linux or OSX,
    2. open a terminal and cd into the project directory,
    3. run composer install,
      • depending on how you installed Composer, you may have to run php composer.phar install instead,
    4. wait for Composer to do its thing.

    Composer will download your dependencies, putting the code into vendor/, and generate an autoloader class that hooks everything together. Depending on what the dependencies are it might also do other things, like linking all CLI binaries to vendor/bin/.

    点赞 评论 复制链接分享