Answer the question
In order to leave comments, you need to log in
How to correctly connect classes using use? Where does composer install packages in Laravel?
Hi everybody! For a project based on laravel, it was required to use a lib to work with the VK API at the link: https://github.com/getjump/VkApiPHP
I had two questions:
1. How can I connect this lib to my controller (laravel)?
2. Where does composer install libs in the project?
Answer the question
In order to leave comments, you need to log in
1. PHP - Namespaces
2. Composer - Dependency Manager for PHP
Read...
1) All packages for Laravel are installed by the composer in the /vendor/ folder
2) Classes can have any namespace, but usually it is Vendor\Package\Class
3) Usually, package instructions indicate how to install everything and connect correctly, but in your case it would be more logical to place the following code at the very top of the controller in which you are going to use the API:
use getjump\Vk\Core as VK;
use getjump\Vk\Auth as VKAuth;
use getjump\Vk\Wrapper\Friends as VKFriends;
// и т.д.
getjump\Vk\Core::
And use the construction
insteadVK::
Since Laravel itself is installed through composer, the dependencies use the same autoload.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question