Laravel Package (Companies House API)

Companies House has release beta version of their API which can be used to obtain different information related to companies. This API is currently in BETA state but is open for public use.

I have been working on developing Laravel package to consume Companies House API and have done some progress. This is an open source package and is already up on GitHub and Packagist and can be used simply by requiring:

composer require ghazanfarmir/laravel-companies-house

HOW TO USE

use GhazanfarMir\CompaniesHouse\Facades\CompaniesHouse;

Search

CompaniesHouse::search()->all('Ebury');
CompaniesHouse::search()->companies('Ebury');
CompaniesHouse::search()->officers('Ebury');
CompaniesHouse::search()->disqualified_officers('Ebury');

Companies

CompaniesHouse::company('07086058'); // returns an object
CompaniesHouse::company('07086058')->get();
CompaniesHouse::company('07086058')->registered_office_address();
CompaniesHouse::company('07086058')->officers();
CompaniesHouse::company('07086058')->insolvency();
CompaniesHouse::company('07086058')->establishments();
CompaniesHouse::company('07086058')->registers(); // returns 404
CompaniesHouse::company('07086058')->excemptions();

Charges

CompaniesHouse::charges('07086058')->all();
CompaniesHouse::charges('07086058')->find(chargesId);

Filing History

CompaniesHouse::filingHistory('07086058')->all();
CompaniesHouse::filingHistory('07086058')->find('MzE4MjE3NzM2MGFkaXF6a2N4');

Render Template without a custom Controller – Symfony

In any MVC framework when you want to show any page you would normally create a controller and render template from within the controller.

Laravel Framework

class BooksController extends Controller
{
    /**
     * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
     */
    public function index()
    {
        $books = Book::all();
        return view('books.index', compact('books'));
    }
}

Symfony Framework

class BooksController extends AbstractController {

	/**
	 * @Route("/")
	 *
	 * @return Response
	 */
	public function index() {
             $books = $this->getDoctrine()->getRepository(Books::class);
             return $this->render("books/index.html.twig", [
			'books' => $liveAlarms,
			]
		);
       }
}

But in Symfony, if you are rendering a simple template, for instance, static content which doesn’t need any data from Controller you can still render it without creating a Controller by using built-in TemplateController.

# config/routes.yaml
acme_privacy:
    path:         /privacy
    controller:   Symfony\Bundle\FrameworkBundle\Controller\TemplateController
    defaults:
        template: static/privacy.html.twig
    methods: GET