SuperAPI AI Directory

basercms4-development

Coding & development

View repository

Updated 10-15 17:24

About this skill

Development rules for baserCMS 4.x (CakePHP 2.x) + jQuery projects

This project is developed according to the following technology stack and design policy.


Technologies Used

  • baserCMS 4.x is used (internally, CakePHP 2.10 base)
  • Backend: PHP 7.4 - 8.2 / CakePHP 2.x
  • Database: MySQL 5.7 to 8.0
  • Frontend: jQuery 1.x-3.x (multiple versions may coexist within the project)
  • HTTP server: Apache (mod_rewrite enabled)

Directory Structure Rules

  • While the MVC structure conforms to CakePHP 2.x,baserCMS is mainly built on a per-plugin basis
    • app/Plugin/{Plugin名}/Controller/, Model/, View/ are each placed in
  • Common parts (header, footer, etc.)are placed in the Elements/ directory within the theme
    • Mainly:theme/{テーマ名}/Elements/
    • In some environments:app/webroot/theme/{テーマ名}/Elements/
  • Layouts are also placed within the theme
    • Mainly:theme/{テーマ名}/Layouts/
    • In some environments:app/webroot/theme/{テーマ名}/Layouts/
    • $this->layout allows switching
  • Admin screen systems are controlled by /admin/ prefixed URL routing
    • Files used:app/Config/core.php
    • Definition content:Configure::write('Routing.prefixes', array('admin'));

Coding Policy (baserCMS4-specific)

Please also refer to the coding policy in the common rules.

  • Function-based and procedural code is adopted more often than class-based code
  • JavaScript is written within <script> tags in View files or in .js files
  • Ajax communication is performed using jQuery ($.ajax())
  • ES6 syntax (Promise, fetch, import/export) is not used
  • SPA technologies such as React or Vue are not introduced for frontend implementation
    • There are some places where they are partially used

Naming Conventions (baserCMS4-specific)

Please also refer to the naming conventions in the common rules.

* Naming conventions of baserCMS and CakePHP (Controller, Helper, Model, etc.) are followed as-is


Logging and Error Handling Policy (baserCMS4-specific)

Please also refer to the logging and error handling policy in the common rules.

Purpose: /log Improving the accuracy of suggestions for aliases and exception handling implementations

baserCMS4-specific implementation methods

  • In PHP, CakeLog::error() or error_log() is used
  • In JavaScript, console.error() is treated as a temporary measure, and server transmission should also be considered for the final implementation

Implementation example (written in the configuration file for baserCMS):

/**
 * 専用ログ
 */
if (!defined('PROJECT_PLUGIN_ACTION')) {
	define('PROJECT_PLUGIN_ACTION', 'project_plugin_action');
	CakeLog::config('project_plugin_action', [
		'engine' => 'FileLog',
		'types' => ['project_plugin_action'],
		'file' => 'project_plugin_action',
		'size' => '5MB',
		'rotate' => 5,
	]);
}

// ログを取りたい箇所に記述する
$this->log('Start', PROJECT_PLUGIN_ACTION);
$this->log(print_r($array, true), PROJECT_PLUGIN_ACTION);

Libraries and Helpers Used

  • BcBaserHelper, BcFormHelper, BcHtmlHelper Utilize baserCMS-specific helpers such as
  • HTML output is $this->BcBaser->css(), $this->BcBaser->img() etc., and keep handwriting to a minimum

Rules for handling files and directories

Purpose: When AI analyzes or suggests code, handling it appropriately based on the following three classifications prevents unnecessary suggestions and erroneous changes.

  • Read-only: Framework core files, etc., which may be referenced but must not be modified
  • For configuration investigation: Referenced to check configuration values, but modification is prohibited

Clearly distinguish how files and directories are handled based on the following classifications.

Read-only (referenced by AI/humans but not altered)

  • lib/Baser/(baserCMS core)
  • lib/Cake/(CakePHP core)

For configuration investigation (for understanding the contents; used to retrieve values, etc., but modification is prohibited)

  • app/Config/database.php(checking connection settings)
  • app/Config/core.php(investigating routing, debug settings, etc.)
  • app/Console/cake(checking CLI specifications)
  • app/webroot/index.php, .htaccess(startup files, Rewrite settings)

Server configuration and constraints (specific to baserCMS4)

Also refer to the server configuration and constraints in the common rules.

  • baserCMS is placed under the document root (index.php is the root)

Constraints and cautions

  • Customization based on baserCMS's standard configuration is fundamental (core hacks prohibited)
  • Proposals to replace it with other frameworks such as Laravel or CakePHP 4 are unnecessary
  • Proposals regarding modern JS frameworks (Vue, React, etc.) are also unnecessary
  • When considering or making proposals, consider compatibility with the existing configuration and its impact as the highest priority
  • Strive for implementations that take PHP 7.2 constraints into account
  • Maintain compatibility with jQuery 1.x to 3.x
  • Use SQL statements that work on both MySQL 5.7 and 8.0