Home  >  Article  >  Backend Development  >  How to introduce third-party references installed by composer in vendor in laravel

How to introduce third-party references installed by composer in vendor in laravel

WBOY
WBOYOriginal
2016-08-04 09:19:222451browse

In my laravel framework, I want to create a full-text search function, but I think the efficiency based on mysql's like%xx% is too low. After comparison, xunsearch supports Chinese search, so I decided to use it.
After installing xunsearch on the vendor in the root directory composer, I directly require the entry file according to the traditional method

How to introduce third-party references installed by composer in vendor in laravel

But if I use new XS(), it will prompt me

How to introduce third-party references installed by composer in vendor in laravel
XS not found.
Laravel references the code in the vendor, can’t it be required directly? Do I need to use a server container or something? I looked at the documentation and I don’t quite understand how to use it.............

Reply content:

In my laravel framework, I want to create a full-text search function, but I think the efficiency based on mysql's like%xx% is too low. After comparison, xunsearch supports Chinese search, so I decided to use it.
After installing xunsearch on the vendor in the root directory composer, I directly require the entry file according to the traditional method

How to introduce third-party references installed by composer in vendor in laravel

But if I use new XS(), it will prompt me

How to introduce third-party references installed by composer in vendor in laravel
XS not found.
Laravel references the code in the vendor, can’t it be required directly? Do I need to use a server container or something? I looked at the documentation and I don’t quite understand how to use it.............

You first take a look at the xunsearch introduced by composer. There is a composer.json under the vendor. It tells you that its namespace has a PSR path in autoload

Laravel has the xunsearch extension package, and Laravel uses the namespace supported since PHP5.3, so there is no need for a require/include file.

Laravel uses psr4 automatic loading standard, you only need to configure the loading path in composer.json

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn