Laravel Companies House

Install

Installation

Take a note of the API key and add it to your .env file

COMPANIES_HOUSE_KEY=

Via Composer

composer require dcblogdev/laravel-companies-house

You can publish the config file with:

php artisan vendor:publish --provider="Dcblogdev\CompaniesHouse\CompaniesHouseServiceProvider" --tag="config"

When published, the config/companieshouse.php config file contains:

<?php

return [

    /*
    * the key is set from the Companies House to identify the application
    * https://developer.companieshouse.gov.uk/developer/applications
    */
    'key' => env('COMPANIES_HOUSE_KEY'),
];

Usage

In a controller import the class:

use Dcblogdev\CompaniesHouse\Facades\CompaniesHouse;

In a view or closure call the facade:

CompaniesHouse::get('path');

You call CompaniesHouse followed by get:: this will run a GET request followed by the endpoint you want to call, for instance, to call company profile (https://developer.companieshouse.gov.uk/api/docs/company/company_number/company_number.html)

CompaniesHouse::get('company/123456');

To make things a little easier there is also trait classes provided.

Each Trait class provides convenient methods that call the endpoints, processes the data, and returns JSON of the results.

Laravel Modules Your Logo Your Logo Your Logo

Become a sponsor

Help support the blog so that I can continue creating new content!

Sponsor

My Latest Book

Modular Laravel Book - Laravel: The Modular way

Learn how to build modular applications with Laravel Find out more

Subscribe to my newsletter

Subscribe and get my books and product announcements.

Fathom Analytics $10 discount on your first invoice using this link

© 2006 - 2024 DC Blog. All code MIT license. All rights reserved.