Skip to content

mrlinnth/ci4-cockpit-starter

 
 

Repository files navigation

CodeIgniter 4 + Blade + Cockpit CMS + Aimeos Starter

A modern starter template integrating CodeIgniter 4, BladeOne templating, Cockpit CMS for content management, and Aimeos for e-commerce product catalogs. API-driven architecture with no local database required.

Features

  • CodeIgniter 4 - Lightweight PHP framework
  • BladeOne - Laravel Blade templating engine
  • Cockpit CMS - Headless CMS for content via API
  • Aimeos - E-commerce product catalog via API
  • Tailwind CSS + daisyUI - Modern styling with components
  • Built-in Caching - Optimized API calls

Quick Start

# Clone and install
git clone <repository-url> && cd ci4
composer install
npm install

# Configure environment
cp env.example .env
# Edit .env with your Cockpit and Aimeos API settings

# Build CSS and start server
npm run build:css
chmod -R 755 writable/
php spark serve

Visit: http://localhost:8080

Requirements

  • PHP 8.1+ with extensions: intl, mbstring, json, libcurl
  • Composer
  • Node.js & npm
  • Cockpit CMS instance with API key
  • Aimeos instance with API key (optional)

Configuration

Add to .env:

# Cockpit CMS
cockpit.apiUrl = https://your-cockpit-instance.com
cockpit.apiToken = your-api-token

# Aimeos (optional)
aimeos.apiUrl = https://your-aimeos-instance.com/jsonapi
aimeos.apiToken = your-api-token

Usage

Controller Pattern

All web pages extend WebController:

class Home extends WebController
{
    public function index()
    {
        // Cockpit CMS content
        $content = $this->cockpit->getSingletonCached('homepage');

        // Aimeos products
        $products = $this->aimeos->getProductsCached();

        return $this->render('home', compact('content', 'products'));
    }
}

Blade Views

Views use Blade syntax in app/Views/*.blade.php:

@extends('layouts.master')

@section('content')
    <h1>{{ $content['title'] }}</h1>

    @foreach($products as $product)
        <div class="card">{{ $product['attributes']['product.label'] }}</div>
    @endforeach
@endsection

Available Services

use Config\Services;

Services::blade()    // Blade templating
Services::cockpit()  // Cockpit CMS API
Services::aimeos()   // Aimeos e-commerce API

Cockpit CMS Methods

$this->cockpit->getSingletonCached($name, $ttl);
$this->cockpit->getCollectionCached($name, $filter, $ttl);

Aimeos Methods

$this->aimeos->getProductsCached();
$this->aimeos->getProductCached($id);
$this->aimeos->getCategoriesCached();
$this->aimeos->searchProductsCached($query);

Documentation

Guide Description
BLADE.md Complete Blade templating guide
STYLING.md Tailwind CSS + daisyUI styling
ARCHITECTURE.md Architecture rules and project structure

External Resources

License

MIT License

About

CodeIgniter 4 app starter to use with Cockpit headless cms

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages

  • PHP 55.9%
  • CSS 31.4%
  • Blade 11.7%
  • Other 1.0%