Composer references local git as the source Library

Source: Internet
Author: User
Composer references local git as the source library. most PHP users love and hate composer. many libraries do not need to be downloaded after composer require, although many taoyou have made images in China, they are still updated as a whole for the bower Library.

So how can we use only the basic functions of composer to serve ourselves? The official website of composer has an introduction. you only need to add several lines of code to composer. json ..

JavaScript code

"repositories":[         {             "type":"git",             "url":"/var/www/gouki/test/"         },     ]  

In the above code,/var/www/gouki/test is one of my git libraries. It is also built according to composer standards. There is only one composer. json file:

JavaScript code

{      "name":"gouki/test",      "description":"test",      "authors":[          {              "name":"gouki",              "email":"xxxx@qq.com"          }      ],      "minimum-stability":"dev",      "require":{},      "autoload":{          "psr-4":{              "gouki\\test\\":"src/"         }     },     "extra":{         "branch-alias":{             "dev-master":"1.0.x-dev"          }      }  }  

The namespace used in the code under the src directory is gouki \ test, and then added to the original project composer. json:

JavaScript code

"require":{          "gouki/test":"dev-master"      },  

Finally, run the composer update command. you will see that the root directory of the project has a more vender directory, and there will also be a more gouki/test directory under the vender Directory. at this point, the project has been introduced successfully, if you are not at ease, check whether gouki/test is available in vendor/composer/autoload_psr4.php.

The reason for doing so is that the speed mentioned above, of course, also has the cost of a small team. For example, if you write a class, you can directly load composer.

This is the problem. if you put it online, the above

XML/HTML code

  1. "Repositories ":[
  2. {
  3. "Type": "git ",
  4. "Url": "/var/www/gouki/test /"
  5. },
  6. ]
  7. Change:
  8. "Repositories ":[
  9. {
  10. "Type": "git ",
  11. "Url": "http://xxxx.xxx.xxx/git"
  12. },
  13. ]

If git is public, no processing is required. If git needs to be logged on, it must be in the root directory of the project (and composer. add an auth. json, which contains two or three lines of code

JavaScript code

{        "http-basic":{            "http://xxxx.xxx.xxx/git":{                "username":"",                "password":""            }        }    }    

Of course, if you are using ssh-free git, you can use another method. So far, a small self-built composer source has been completed.

This site uses the copyright agreement, requiring signatures, non-commercial and consistent. this site welcomes reprinting of any non-commercial applications, but it must be noted from"

", Retain the original link. In addition, you must mark the original title and link.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.