1. Go to this page and download the library: Download bannerstop/odoo-connect library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
bannerstop / odoo-connect example snippets
Bannerstop\OdooConnect\Client\OdooConnection;
use Bannerstop\OdooConnect\Client\OdooClient;
use Bannerstop\OdooConnect\Builder\RequestBuilder;
use Bannerstop\OdooConnect\Service\OrderService;
use Bannerstop\OdooConnect\Service\CustomerService;
use Bannerstop\OdooConnect\Enum\Field\OrderField;
use Bannerstop\OdooConnect\Enum\Field\CustomerField;
use Bannerstop\OdooConnect\Enum\State;
$client = new OdooClient(
new OdooConnection(
baseUrl: 'api-url',
apiKey: 'api-key',
db: 'database-name'
)
);
$requestBuilder = new RequestBuilder($client);
$orderService = new OrderService($requestBuilder);
$customerService = new CustomerService($requestBuilder);
// Fetch order by order ID with specific fields
$order = $orderService->getOrderByOrderId('3136366', [OrderField::ORDER_ID, OrderField::STATE]);
print_r($order);
// Fetch orders by date range and state
$orders = $orderService->getOrdersByDate('2025-01-18', '2025-01-19', State::QUOTE, [OrderField::ORDER_ID, OrderField::AMOUNT_TOTAL]);
print_r($orders);
// Example with DTOs
$orderDTO = $orderService->getOrderByOrderId('3136366');
$customerDTO = $customerService->getCustomerById($orderDTO->customerId);
print_r($orderDTO);
print_r($customerDTO);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.