Home > Article > Backend Development > How to introduce third-party references installed by composer in vendor in laravel
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
But if I use new XS(), it will prompt me
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.............
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
But if I use new XS(), it will prompt me
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