Search by

klucznik / cog-framework

klucznik

PHP framework built on Symfony components

Package info

github.com/klucznik/cog-framework

pkg:composer/klucznik/cog-framework

Statistics

Installs: 1

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v0.9.2 2026-09-09 23:09 UTC

This package is auto-updated.

Last update: 2026-09-10 20:18:50 UTC


README

A PHP framework built on Symfony components, with a database code generator that produces typed model classes from an existing MySQL schema.

Requirements

  • PHP 8.5 or newer
  • Extensions: mbstring, json, dom, libxml, mysqli, simplexml

Installation

composer require klucznik/cog-framework

Bootstrapping

The framework is initialized once per request through Cog\BaseApplication::initialize(). The repository ships a working example of this wiring:

These are reference examples, not files you install. Copy them into your own project and adjust the paths to your Composer autoloader.

Cog\BaseApplication is meant to be extended, you should create your own Application class with your own modifications / customizations.

Code generation

The generator reads a codegen.xml configuration file describing the database connection and output paths. Copy codegen.xml-dist to codegen.xml, fill in your settings, then run:

./cog db:codegen

Testing

The suite runs against a MySQL fixture database. Load it once:

mysql -u root -p < src/Test/cog_framework_test.sql

Connection details come from the COG_TEST_DB_* environment variables; override the defaults in phpunit.xml.dist by copying it to phpunit.xml (git-ignored). Then:

composer test

The bootstrap runs the code generator against that database before any test executes, into the git-ignored .phpunit.codegen/ build directory, and registers an autoloader for the resulting Generated\ and App\ classes. TestCodegen runs first and reports any generation failure; the rest of the suite can rely on the generated ORM layer being present.

PostgreSQL

TestPostgreSql exercises the PostgreSQL adapter against a parallel fixture. It is optional - every test in it skips when the pgsql extension, the server or the fixture is missing, so the suite stays green without one. To run it, load the schema and let the COG_TEST_PG_* variables point at it:

createdb cog_framework_test && psql -d cog_framework_test -f src/Test/cog_framework_test_pg.sql

The adapter is not at parity with the MySQL one: PostgreSQL has no self-updating timestamp column, so the code generator emits no optimistic locking for a PostgreSQL schema. See the header of src/Test/cog_framework_test_pg.sql.

License

MIT — see LICENSE.