PHP Moip class autoloader

Asked

Viewed 340 times

0

How do I make this require 'vendor/autoload.php', it does not come in the documentation.

 <?php
 require 'vendor/autoload.php';

 use Moip\Moip;
 use Moip\MoipBasicAuth;

 $endpoint = 'test.moip.com.br';
 $token = '01010101010101010101010101010101';
 $key = 'ABABABABABABABABABABABABABABABABABABABAB';

 $moip = new Moip(new MoipBasicAuth($token, $key), $endpoint);

 $customer = $moip->customers()->setOwnId('sandbox_v2_1401147277')
                          ->setFullname('Jose Silva')
                          ->setEmail('[email protected]')
                          ->setBirthDate('1988-12-30')
                          ->setTaxDocument('33333333333')
                          ->setPhone(11, 66778899)
                          ->addAddress('BILLING',
                                       'Avenida Faria Lima', 2927,
                                       'Itaim', 'Sao Paulo', 'SP',
                                       '01234000', 8);

 print_r($order = $moip->orders()->setOwnId('sandbox_v2_1401147277')
                    ->addItem('Pedido de testes Sandbox - 1401147277', 1, 'Mais info...', 10000)
                    ->setShippingAmount(100)
                    ->setCustomer($customer)
                    ->create());

Thank you.

1 answer

1

Moip’s new SDK uses the Composer so just install the project dependencies and autoload will do all the work for you.

You must install Composer in your project, see here (content in English).

After the installed Composer and with the project cloned on machine, run the command

composer install

After the dependencies have been installed you can run the sample php. usually in your browser.

The documentation of new SDK PHP Moip is also up to date, I think it might help.

SDK Moip v2(php): https://github.com/moip/moip-sdk-php

Browser other questions tagged

You are not signed in. Login or sign up in order to post.