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.1+ Enable intl, json, mbstring, gd, curl, openssl. Matches composer.json platform.
Composer 2.5+ Manage PHP dependencies.
Node.js 18 LTS Needed if you maintain public/be-assets.
npm 8+ Package manager for backend assets.
Database MySQL/MariaDB Any CodeIgniter-supported driver works. Configure via .env.
Web server Apache/Nginx/CI4 spark Point document root to public/.

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)
  uploads/           Media storage (ensure writable)
writable/            Cache, logs, temporary files (must be writable)
vendor/              Composer packages

Essential configuration files include composer.json, the contents of app/Config, and the environment overrides stored in .env.

3. Getting Started

  1. Clone & install
    git clone <repo-url> ci4ms
    cd ci4ms
    composer install
  2. Prepare the environment
    cp env .env
    php spark env development

    Set app.baseURL, database.default.*, mail credentials, and security options.

  3. Migrate & seed
    php spark migrate
    php spark db:seed Ci4msDefaultsSeeder  # prompts for admin account details
    php spark key:generate
    php spark create:route
  4. Serve locally
    php spark serve

    Visit http://localhost:8080 for the front-end and /backend for the admin.

Tip: Re-running the seeder on a populated database can duplicate data. Truncate first if needed.

4. Dependency Management

Composer

Core packages include ci4commonmodel, sql2migration, ext_module_generator (exposes php spark make:module), claviska/simpleimage, seunmatt/codeigniter-log-viewer, gregwar/captcha, melbahja/seo, phpmailer/phpmailer, and studio-42/elfinder.

composer install
composer update vendor/package
composer outdated

Node (Admin assets)

The admin panel pulls JS dependencies from public/be-assets (Tagify, Monaco editor, elFinder theme, etc.).

cd public/be-assets
npm install
# add build/watch scripts if you introduce a bundler

Document any new build tooling in this handbook when added.

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/uploads/media/ (ensure writable, include .trash folder).

File Editor & Themes

  • Fileeditor: Uses realpath guards; limit use to trusted roles.
  • Themes: Located in public/templates/<theme>; uploads unzip to writable/tmp before install.
  • Required theme files: info.xml, screenshot.png (checked by backend filter).

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.