Laravel Developer
David Carr
Web Developer
All Posts Archives Categories Authors
About Books Packages Templates Contact
Blog
All Posts Archives Categories Authors
About Books Packages Templates Contact
Laravel Companies House
Laravel Packages
Laravel Microsoft Graph Laravel Xero Laravel Sent Emails Laravel Dropbox Laravel Box Laravel Companies House Laravel Countries Laravel Eventbrite Laravel Blade Components
PHP Packages
PDO Wrapper PHP find and replace JSON SQL Import IMAP Export CSV Pagination
v1 v2
Navigation
  • Introduction
  • Install
  • Companies
  • Officer
  • Search
Navigation
  • Introduction
  • Install
  • Companies
  • Officer
  • Search

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.

Table of Contents
  • Installation
  • Usage

DCBlog

Practical tutorials, code snippets, and in-depth guides for modern web development. Helping developers build better applications since 2009.

Subscribe to my newsletter for the latest updates on my books and digital products.

© 2009 - 2025 DC Blog. All rights reserved.

Privacy Policy • Terms of Service