Laravel How to reference a third-party (custom) library

Source: Internet
Author: User
Tags autoload
Want to do a Web crawl function, the underlying use of PHP laravel framework.

Here we use the Phpquery Library to implement Web page crawling, which is not introduced here.

Need to know can Baidu, or so I pits.

Not scientific Internet can directly click on my upload download package--| how to upload ... Own Baidu Bar, the current version is phpQuery-0.9.5.386

-------------------------------------

Let's make a statement about the version I'm using:

laravel5.1;

phpQuery-0.9.5.386;

-------------------------------

began to think that as long as the entire package into the library Laravel project can be used, sure enough, the pattern Tucson broken.

Given the good line in the Laravel framework package, it is necessary to set the Laravel autoload->class map

-------

1, first in the app directory to create a new folder, named Libs (customizable)

2. (optional) consider that many libraries may be referenced later so, create a phpquery folder under Libs

3. Locate the Composer.json file under the root directory

4, find the definition of Composer.json (see my notes)

"AutoLoad": {        "Classmap": [            "Database",            "app/libs/phpquery"//Add me plus me        ],        "psr-4": {            "app\\" : "app/"        }    ,

5. Run terminal, CD to project path, execute

Composer Dumpautoload

--------------------------

You can then use the Phpquery in the project happily, with the following simple usage:

Use Phpquery;
Phpquery::newdocumentfile (' http://www.baidu.com '); $companies = PQ (' body '); return $companies;

Note: If you want to add another third-party library, repeat the 2-5 step.

The above describes how Laravel refers to a third-party (custom) library, including aspects of the content, hoping to be interested in the PHP tutorial friends helpful.

  • Related Article

    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.