How to set the loading sequence of composer?

Source: Internet
Author: User
Tags autoload composer install
As in the following database file: {code ...} then composer. in the json file, autoload is: {code ...} now I want to add a global initialization function to the database Xyz when running composerinstall. Specifically, add the file x. php, and the content of this file is as follows :... for example:

$ cd src/lib/Xyz/$ lsa.php b.php c.php

Thencomposer.jsonFileautoloadIs:

autoload: {  psr-4: {    Xyz\\: src/lib/Xyz/  }}

Now I want to runcomposer installTo the databaseXyzAdd a global initialization function. Specifically, add a file.x.phpAnd the content of this file is as follows:


  

Equivalent,x.phpThe file is the wholeXyzThe first thing the library executes is what other php files need.

Therefore, how to writecomposer.jsonWhat about files?

Reply content:

For example:

$ cd src/lib/Xyz/$ lsa.php b.php c.php

Thencomposer.jsonFileautoloadIs:

autoload: {  psr-4: {    Xyz\\: src/lib/Xyz/  }}

Now I want to runcomposer installTo the databaseXyzAdd a global initialization function. Specifically, add a file.x.phpAnd the content of this file is as follows:


   

Equivalent,x.phpThe file is the wholeXyzThe first thing the library executes is what other php files need.

Therefore, how to writecomposer.jsonWhat about files?

Put require in the first PHP file in your library.

Does composer seem to be used for this purpose? It only manages dependencies, not the code in the package. You can modify the source code of your Xyz database by yourself.

@ Leunggamciu @ incNick Thank you. In the source code entry file, require is a solution. I just want to know if composer has such a method. I checked the information andautoloadFields can bepsr-4A parallel field:filesMaybe it can be used. I took some time to try it and then replied.

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.