Download the PHP package codebar-ag/laravel-bexio without Composer
On this page you can find all versions of the php package codebar-ag/laravel-bexio. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download codebar-ag/laravel-bexio
More information about codebar-ag/laravel-bexio
Files in codebar-ag/laravel-bexio
Package laravel-bexio
Short Description Bexio integration with Laravel
License MIT
Homepage https://github.com/codebar-ag/laravel-bexio
Informations about the package laravel-bexio

This package was developed to give you a quick start to the Bexio API.
π‘ What is Bexio?
Bexio is a cloud-based simple business software for the self-employed, small businesses and startups.
π Requirements
Package | PHP | Laravel |
---|---|---|
v13.0.0 (alpha) | ^8.3 - ^8.5 | 13.x |
v12.0.0 | ^8.2 - ^8.4 | 12.x |
v11.0.0 | ^8.2 - ^8.3 | 11.x |
v1.0.0 | ^8.2 | 10.x |
Authentication
The package supports multiple authentication methods for both single-tenant and multi-tenant applications:
Method | Supported |
---|---|
API token | β |
OAuth | β |
βοΈ Installation
You can install the package via composer:
Optionally, you can publish the config file with:
π Authentication Setup
Environment Variables
Add the following environment variables to your .env
file:
You can retrieve your API token or OAuth credentials from your Bexio Developer Dashboard.
For OAuth credentials, you'll need to register your application in the Bexio Developer Portal.
π Usage
Single Tenant Authentication
For applications that only need to authenticate with one Bexio account:
Token Authentication
OAuth Authentication
OAuth Flow
The package provides built-in routes for OAuth authentication:
- Redirect to Bexio:
/bexio/redirect
- OAuth Callback:
/bexio/callback
You can customize the route prefix and middleware in your config file:
OAuth Callback Response
After the OAuth callback is processed, the user will be redirected to the URL specified in your configuration (config('bexio.redirect_url')
or /
by default) with flash session data indicating the result:
Success Response:
Error Responses:
Handling the callback in your controller:
Multi-Tenant Authentication
For applications that need to authenticate with multiple Bexio accounts:
Token Authentication (Multi-Tenant)
OAuth Authentication (Multi-Tenant)
For multi-tenant OAuth, you need to create custom resolvers and bind them to Laravel's service container.
Step 1: Create Custom Config Resolver
this example is with the auth user as a tenant, but you can easily modify it to another model of your choice.
Step 2: Create Custom Authentication Store Resolver
this example is with the auth user as a tenant, but you can easily modify it to another model of your choice. you are also not required to use cache, you could store the authenticator on the model's database entry by updating a column on the model rather than using the Cache facade.
Step 3: Register Custom Resolvers
In your AppServiceProvider
or a dedicated service provider:
Step 4: Using Multi-Tenant OAuth
Custom OAuth Authentication Validation (Optional)
You can implement custom validation logic that runs before the OAuth authenticator is stored. This is useful for:
- Validating user permissions with API calls
- Checking company/organization restrictions
- Implementing custom business logic
- Adding custom error handling with redirects
This feature is not limited to multi-tenant setups; it can be used in single-tenant applications as well.
Create Custom Validation Resolver:
Register the Custom Validator:
Add to your service provider:
Validation Result Types:
Error Handling:
When validation fails, users will be redirected with these session variables:
Available OAuth Scopes
The package automatically applies default OAuth scopes for OpenID Connect authentication. These default scopes are:
openid
- Required for OpenID Connect authenticationprofile
- Access to basic profile informationemail
- Access to email addresscompany_profile
- Access to company profile informationoffline_access
- Enables refresh token functionality for long-term access
These default scopes are automatically included in all OAuth requests and cannot be removed. You can add additional scopes as needed for your application.
The package provides enums for OAuth scopes:
π§ Advanced Configuration
Custom Cache Store
You can specify a custom cache store for OAuth token storage:
Custom Route Configuration
Route Middleware
The OAuth routes (/bexio/redirect
and /bexio/callback
) automatically include the web
middleware group by default. You can add additional middleware using the route_middleware
configuration:
Examples:
Common Use Cases:
- Authentication Required: Use
['auth']
to ensure only authenticated users can initiate OAuth flow - Email Verification: Use
['auth', 'verified']
for applications requiring email verification - Rate Limiting: Use
['throttle:10,1']
to limit OAuth attempts - Custom Authorization: Add your own middleware to control who can access OAuth routes
The middleware will be applied to both OAuth routes:
GET /bexio/redirect
- Initiates OAuth flowGET /bexio/callback
- Handles OAuth callback from Bexio
Basic Usage
After setting up authentication, create a connector instance:
Responses
The following responses are currently supported for retrieving the response body:
Response Methods | Description | Supported |
---|---|---|
body | Returns the HTTP body as a string | β |
json | Retrieves a JSON response body and json_decodes it into an array. | β |
object | Retrieves a JSON response body and json_decodes it into an object. | β |
collect | Retrieves a JSON response body and json_decodes it into a Laravel collection. Requires illuminate/collections to be installed. | β |
dto | Converts the response into a data-transfer object. You must define your DTO first | β |
See https://docs.saloon.dev/the-basics/responses for more information.
Enums
We provide enums for the following values:
Enum | Values |
---|---|
Accounts: SearchFieldEnum | ACCOUNT_NO(), self FIBU_ACCOUNT_GROUP_ID(), NAME(), ACCOUNT_TYPE() |
Accounts: AccountTypeEnum | EARNINGS(), EXPENDITURES(), ACTIVE_ACCOUNTS(), PASSIVE_ACCOUNTS(), COMPLETE_ACCOUNTS() |
AdditionalAddresses: AddSearchTypeEnum | ID(), ID_ASC(), ID_DESC(), NAME(), NAME_ASC(), NAME_DESC() |
CalendarYears: VatAccountingMethodEnum | EFFECTIVE(), NET_TAX() |
CalendarYears: VatAccountingTypeEnum | AGREED(), COLLECTED() |
ContactGroups: OrderByEnum | ID(), ID_ASC(), ID_DESC(), NAME(), NAME_ASC(), NAME_DESC() |
ContactRelations: OrderByEnum | ID(), ID_ASC(), ID_DESC(), CONTACT_ID(), CONTACT_ID_ASC(), CONTACT_ID_DESC(), CONTACT_SUB_ID(), CONTACT_SUB_ID_ASC(), CONTACT_SUB_ID_DESC(), UPDATED_AT(), UPDATED_AT_ASC(), UPDATED_AT_DESC() |
Contacts: OrderByEnum | ID(), ID_ASC(), ID_DESC(), NR(), NR_ASC(), NR_DESC(), NAME_1(), NAME_1_ASC(), NAME_1_DESC(), UPDATED_AT(), UPDATED_AT_ASC(), UPDATED_AT_DESC() |
ContactSectors: OrderByEnum | ID(), ID_ASC(), ID_DESC(), NAME(), NAME_ASC(), NAME_DESC() |
IbanPayments: AllowanceTypeEnum | FEE_PAID_BY_SENDER(), FEE_PAID_BY_RECIPIENT(), FEE_SPLIT(), NO_FEE() |
IbanPayments: StatusEnum | OPEN(), TRANSFERRED(), DOWNLOADED(), ERROR(), CANCELLED() |
ManualEntries: TypeEnum | MANUAL_SINGLE_ENTRY(), MANUAL_GROUP_ENTRY(), MANUAL_COMPOUND_ENTRY() |
QrPayments: AllowanceTypeEnum | FEE_PAID_BY_SENDER(), FEE_PAID_BY_RECIPIENT(), FEE_SPLIT(), NO_FEE() |
QrPayments: StatusEnum | OPEN(), TRANSFERRED(), DOWNLOADED(), ERROR(), CANCELLED() |
Taxes: ScopeEnum | ACTIVE(), INACTIVE() |
Taxes: TypeEnum | SALES_TAX(), PRE_TAX() |
Titles: OrderByEnum | ID(), ID_ASC(), ID_DESC(), NAME(), NAME_ASC(), NAME_DESC() |
SearchCriteriaEnum | EQUALS(), DOUBLE_EQUALS(), EQUAL(), NOT_EQUALS(), GREATER_THAN_SYMBOL(), GREATER_THAN(), GREATER_EQUAL_SYMBOL(), GREATER_EQUAL(), LESS_THAN_SYMBOL(), LESS_THAN(), LESS_EQUAL_SYMBOL(), LESS_EQUAL(), LIKE(), NOT_LIKE(), IS_NULL(), NOT_NULL(), IN(), NOT_IN() |
Note: When using the dto method on a response, the enum values will be converted to their respective enum class.
DTOs
We provide DTOs for the following:
DTO |
---|
AccountGroupDTO |
AccountDTO |
BankAccountDTO |
AdditionalAddressDTO |
BankAccountDTO |
BusinessActivityDTO |
BusinessYearDTO |
CalendarYearDTO |
CompanyProfileDTO |
ContactAdditionalAddressDTO |
ContactGroupDTO |
ContactRelationDTO |
ContactDTO |
CreateEditContactDTO |
ContactSectorDTO |
CurrencyDTO |
CreateCurrencyDTO |
EditCurrencyDTO |
ExchangeCurrencyDTO |
DocumentSettingDTO |
FileDTO |
EditFileDTO |
FileUsageDTO |
InvoiceDTO |
InvoicePositionDTO |
InvoiceTaxDTO |
PdfDTO |
LanguageDTO |
AddFileDTO |
EntryDTO |
FileDTO |
ManualEntryDTO |
NoteDTO |
PaymentDTO |
PaymentTypeDTO |
ProjectDTO |
JournalDTO |
SalutationDTO |
TaxDTO |
TitleDTO |
UnitDTO |
UserDTO |
VatPeriodDTO |
In addition to the above, we also provide DTOs to be used for create and edit request for the following:
DTO |
---|
CreateCalendarYearDTO |
CreateEditAdditionalAddressDTO |
CreateEditContactAdditionalAddressDTO |
CreateEditContactGroupDTO |
CreateEditContactRelationDTO |
CreateEditContactDTO |
CreateCurrencyDTO |
EditCurrencyDTO |
EditFileDTO |
AddFileDTO |
CreateEditIbanPaymentDTO |
CreateEntryDTO |
CreateManualEntryDTO |
CreateEditNoteDTO |
CreateEditQrPaymentDTO |
CreateEditSalutationDTO |
CreateEditTitleDTO |
Note: This is the preferred method of interfacing with Requests and Responses however you can still use the json, object and collect methods. and pass arrays to the requests.
Examples
Here are some examples of how to use the package with different authentication methods:
Accounts
Addresses
Bank Accounts
Business Years
Calendar Years
Company Profiles
Additional Addresses
Contact Groups
Contact Relations
Contacts
Contact Sectors
Currencies
Files
Iban Payments
Invoices
Languages
Manual Entries
Notes
Payments
Qr Payments
Reports
Salutations
Taxes
Titles
VAT Periods
π§ Testing
Copy your own phpunit.xml-file.
Run the tests:
π Changelog
Please see CHANGELOG for recent changes.
βοΈ Contributing
Please see CONTRIBUTING for details.
Code Style
π§βπ» Security Vulnerabilities
Please review our security policy on reporting security vulnerabilities.
π Credits
- Rhys Lees
- Sebastian Fix
- Kasper Nowak
- All Contributors
- Skeleton Repository from Spatie
- Laravel Package Training from Spatie
- Laravel Saloon by Sam CarrΓ©
π License
The MIT License (MIT). Please have a look at License File for more information.
All versions of laravel-bexio with dependencies
guzzlehttp/guzzle Version ^7.9.2
illuminate/contracts Version ^12.1.1
illuminate/support Version ^12.1.1
saloonphp/cache-plugin Version ^3.0
saloonphp/laravel-plugin Version ^3.5.1
saloonphp/saloon Version ^3.11.2
spatie/laravel-data Version ^4.13.2
spatie/laravel-enum Version ^3.2.0
spatie/laravel-package-tools Version ^1.19.0