CI4MS Engineering

Developer Handbook

Reference this guide whenever you onboard, ship features, or maintain CI4MS. It merges environment requirements, coding conventions, workflow tips, and deployment best practices into a single companion for the engineering team.

1. System Requirements

Layer Required Notes
PHP 8.2+ Enable intl, json, mbstring, gd, curl, openssl extensions. Matches composer.json (8.2).
Composer 2.5+ Used for all PHP dependencies.
Database MySQL / MariaDB Any CodeIgniter-supported driver works. Configure via .env.
Web server Apache / Nginx / php spark serve Production deploys should point to the public/ directory.
Docker Docker Engine 24+ / Desktop Optional but recommended for local development and CI.

2. Repository Layout Highlights

app/                 Application code (controllers, config, libraries, filters)
modules/             Feature modules (Auth, Backend, Blog, etc.)
public/
  index.php          Front controller
  be-assets/         Admin UI build artifacts (CSS/JS)
  templates/         Front-end themes (default shipped)
  media/             Media storage (ensure writable)
writable/            Cache, logs, temporary files (must be writable)
vendor/              Composer packages
.docker/             Dockerfile, Apache vhost, and php.ini
.github/workflows/   GitHub Actions CI pipeline
docs/                Developer documentation (this file and companions)

Key config files:

3. Getting Started

3.1 Standard (local PHP)

  1. Clone & install
    git clone <repo-url> ci4ms
    cd ci4ms
    composer install
  2. Environment
    cp env .env

    Update: app.baseURL, database.default.*, mail credentials, etc.

  3. Prepare routes
    cp app/Config/DefaultRoutes.php app/Config/Routes.php
  4. One-command setup
    php spark ci4ms:setup

    This single command runs all migrations, seeds default data (admin user, sample pages, settings), and prepares the application.

  5. Serve
    php spark serve

3.2 Docker

cp env .env
cp app/Config/DefaultRoutes.php app/Config/Routes.php
# Edit .env: set database.default.hostname=db
docker compose up -d --build
docker exec ci4ms_app composer install
docker exec ci4ms_app php spark ci4ms:setup

Refer to DOCKER_SETUP.md for full configuration details.

4. Dependency Management

Composer packages

The project depends on CodeIgniter 4 and several packages:

  • codeigniter4/framework — Core framework.
  • codeigniter4/shield — Auth and RBAC.
  • ci4commonmodel — Database abstraction.
  • ci4seopro — SEO, JSON-LD, feeds.
  • sql2migration — CLI migration tooling.
  • ext_module_generator — Module scaffolding.
composer install
composer update vendor/package
composer outdated

Frontend Assets

The admin panel and templates use static JS/CSS packages (Tagify, Monaco, etc.). To keep the repository small and performant, we do not use npm or node_modules by default. Hosted statically in plugins/ and vendor/.

If you introduce a bundler (like Vite) in the future, be sure to compile assets and exclude node_modules from version control.

5. Coding Guidelines

6. Modules & Permissions

Permissions are stored in auth_permissions_pages (CRUD JSON flags) and auth_users_permissions (overrides). The Modules\Methods\Controllers\Methods::moduleScan() command inspects routes and helps keep permissions in sync.

Workflow for a new module:

  1. Scaffold with php spark make:module <Name> (provided by ext_module_generator).
  2. Define routes in modules/<Name>/Config/Routes.php with role metadata.
  3. Implement controllers, models, views.
  4. Update permissions (run module scan or insert records manually).
  5. Create migrations/seeds for new tables if required.

Clear cached permissions with php spark cache:clear or cache()->delete("{userId}_permissions").

7. Configuration & Settings Cache

8. Media, File, & Theme Handling

Media Manager

  • elFinder config in Modules\Media\Controllers\Media::elfinderConnection().
  • Allowed MIME types from settings.allowedFiles.
  • Optional WebP conversion via claviska/simpleimage.
  • Storage: public/media/ (ensure writable, include .trash folder).

File Editor & Themes

  • Fileeditor: Uses realpath guards; limit use to trusted roles.
  • Themes: Located under public/templates/<theme>; ZIP uploads extract to writable/tmp.
  • Migrations: Themes can ship migrations inside Database/Migrations/; run on activation.
  • Boilerplate: Generate a starter boilerplate ZIP directly from the Theme Manager panel.
  • Required theme files: info.xml, screenshot.png (checked by backend filter).

Backup & Restore

  • Backup: Database dumps via mysqldump or PHP fallback.
  • Restore: Restore from local ZIPs or server archives.
  • Storage: Backups saved in writable/uploads/backups. Restore directly from the backend or download archives.

9. Public Assets & Front Controller

10. Testing & QA

11. Debugging Tips

12. Deployment Checklist

  1. Switch to CI_ENVIRONMENT=production.
  2. Set the public app.baseURL.
  3. Point the web server root to public/; restrict other directories.
  4. Run migrations/seeds (php spark migrate --all, relevant seeders).
  5. Optional cache warm-up via scripted requests.
  6. Disable the debug toolbar in production.
  7. Set secure permissions (775/664 depending on user/group).
  8. Back up uploads, database, and .env before major upgrades.

13. Contribution Workflow

14. Further Reading & Resources

Update this handbook whenever the stack or workflows evolve so the team always has a current source of truth.

Ship with Confidence

CI4MS is engineered for extensibility. Keep this page bookmarked, share it with the team, and iterate responsibly.