M
M
MrChen2016-04-16 22:30:22
Composer
MrChen, 2016-04-16 22:30:22

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

3 answer(s)
E
Eugene Gavalidi, 2016-04-16
@remotemethod

1. PHP - Namespaces
2. Composer - Dependency Manager for PHP
Read...

A
Andrzej Wielski, 2016-04-17
@wielski

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::

A
Alexander Litvinenko, 2016-04-16
@edli007

Since Laravel itself is installed through composer, the dependencies use the same autoload.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question