- Added cron key to config.php for scheduled tasks. - Created code_style_and_conventions.md to outline PHP version, file naming, DI pattern, controller wiring, Medoo ORM pitfalls, test conventions, caching, and database structure. - Added project_overview.md detailing the purpose, tech stack, architecture, entry points, and key classes of the shopPRO project. - Introduced suggested_commands.md for testing and system utilities commands. - Added task_completion_checklist.md for a structured approach to completing tasks. - Included .DS_Store files in autoload and templates directories for macOS compatibility.
1.4 KiB
1.4 KiB
Code Style and Conventions
PHP Version
PHP 7.4 — no PHP 8.0+ features allowed.
File Naming
- New classes:
ClassName.php(no prefix) - Legacy classes:
class.ClassName.php(leave until migrated)
DI Pattern (all new code)
class ExampleRepository {
private $db;
public function __construct($db) {
$this->db = $db;
}
public function find(int $id): ?array {
return $this->db->get('pp_table', '*', ['id' => $id]);
}
}
Controller Wiring
- Admin:
admin\App::getControllerFactories() - Frontend:
front\App::getControllerFactories() - API:
api\ApiRouter::getControllerFactories()
Medoo ORM Pitfalls
$mdb->delete($table, $where)takes 2 arguments, NOT 3$mdb->get()returnsnullwhen no record, NOTfalse- After
$mdb->insert(), check$mdb->id()to confirm success
Test Conventions
- Extend
PHPUnit\Framework\TestCase - Mock Medoo:
$this->createMock(\medoo::class) - AAA pattern: Arrange, Act, Assert
- Mirror source structure:
tests/Unit/Domain/{Module}/{Class}Test.php
Caching
- Redis via
\Shared\Cache\CacheHandler - Key pattern:
shop\product:{id}:{lang}:{permutation_hash} - Default TTL: 86400 (24h)
- Data serialized — use
unserialize()afterget()
Database
- Table prefix:
pp_ - Key tables:
pp_shop_products,pp_shop_orders,pp_shop_categories,pp_shop_clients