Cockpit implementation in PHP application


I’m aware that headless CMSs such as Cockpit are designed to be used over a variety of platforms (not just websites), but let me explain my specific scenario.

I currently develop websites primarily in monolithic frameworks such as WordPress. I now wish to replace this with Cockpit. At present, the websites that I want to develop are just simple brochure websites - so their content will most likely never be consumed on other platforms.

I want to know what is the best way I should implement Cockpit in my websites? For the front end I will use a custom built PHP framework, or maybe Laravel in some cases. So I guess I could use something like Guzzle for the API calls.

My idea is to place Cockpit in a subfolder of the website structure, and so my clients can access the CMS by going to /cms.

Is there anything wrong with this approach? Is there a better way to do it?



this is totally possible. Just add cockpit in a subfolder and the only thing you have to do is to

include 'cockpitfolder/bootstrap.php'

anywhere in your code to get full access to the cockpit api.

e.g. to get all posts of the posts collection:

$posts = cockpit('collections')->find('posts', [
   'filter' => ['published' => true],
   'limit' => 10


Excellent. So am I right in assuming I would need to include the Cockpit subfolder in my Git repository?


One more question. What is the best way to create “pages” for a website? So let’s say I want to build a 5 page website (home, about, services, service details, contact). I want my client to go in the CMS, click the page and be able to edit the content. Each page has the following fields:

  • Title (SEO)
  • Description (SEO)
  • Heading
  • Sub heading
  • Banner image
  • Content

However some pages will also contain some specific fields, e.g. on the Contact page there will be a field to enter Google Maps embed code.

Now I think the closest thing to achieve this in Cockpit is “Singletons”. The only issue with this is that I would have to create the fields repeatedly for each page. Is there a way to have a singleton which extends a “base” singleton, which contains all of the above fields?