{"id":33981854,"url":"https://github.com/wdes/simple-php-model-system","last_synced_at":"2026-04-25T03:35:14.538Z","repository":{"id":62547016,"uuid":"369779177","full_name":"wdes/simple-php-model-system","owner":"wdes","description":"A simple PHP model system","archived":false,"fork":false,"pushed_at":"2024-07-04T15:51:45.000Z","size":106,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-12-14T16:33:51.633Z","etag":null,"topics":["active-record","active-record-design-pattern","composer-package","model","mysql","pdo-mysql","php","simple"],"latest_commit_sha":null,"homepage":"https://packagist.org/packages/wdes/simple-php-model-system","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wdes.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2021-05-22T10:28:55.000Z","updated_at":"2024-12-16T22:17:44.000Z","dependencies_parsed_at":"2022-11-02T22:15:29.087Z","dependency_job_id":null,"html_url":"https://github.com/wdes/simple-php-model-system","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/wdes/simple-php-model-system","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wdes%2Fsimple-php-model-system","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wdes%2Fsimple-php-model-system/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wdes%2Fsimple-php-model-system/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wdes%2Fsimple-php-model-system/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wdes","download_url":"https://codeload.github.com/wdes/simple-php-model-system/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wdes%2Fsimple-php-model-system/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32249064,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-25T03:17:44.950Z","status":"ssl_error","status_checked_at":"2026-04-25T03:16:45.208Z","response_time":59,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["active-record","active-record-design-pattern","composer-package","model","mysql","pdo-mysql","php","simple"],"created_at":"2025-12-13T03:50:30.572Z","updated_at":"2026-04-25T03:35:14.523Z","avatar_url":"https://github.com/wdes.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# simple-php-model-system\n\n[![Lint and analyse files](https://github.com/wdes/simple-php-model-system/actions/workflows/lint-and-analyse.yml/badge.svg?branch=main)](https://github.com/wdes/simple-php-model-system/actions/workflows/lint-and-analyse.yml)\n[![Run phpunit tests](https://github.com/wdes/simple-php-model-system/actions/workflows/tests.yml/badge.svg?branch=main)](https://github.com/wdes/simple-php-model-system/actions/workflows/tests.yml)\n[![codecov](https://codecov.io/gh/wdes/simple-php-model-system/branch/main/graph/badge.svg)](https://codecov.io/gh/wdes/simple-php-model-system)\n[![Version](http://poser.pugx.org/wdes/simple-php-model-system/version)](https://packagist.org/packages/wdes/simple-php-model-system)\n[![License](http://poser.pugx.org/wdes/simple-php-model-system/license)](https://packagist.org/packages/wdes/simple-php-model-system)\n[![PHP Version Require](http://poser.pugx.org/wdes/simple-php-model-system/require/php)](https://packagist.org/packages/wdes/simple-php-model-system)\n![maintenance-status](https://img.shields.io/badge/maintenance-passively--maintained-yellowgreen.svg)\n\nA simple PHP model system\n\n## Why ?\n\nThe goal of this project is to provide an easy way to use Models in a non composer setup.\nThis is why this project is kept very minimal.\nThe user can copy all classes in `src/` and start using the lib.\nBut this also works in a composer setup.\n\n## How to use\n\n### Connect to an existing PDO connection\n\n```php\n\u003c?php\ndeclare(strict_types = 1);\n\nuse SimplePhpModelSystem\\Database;\n\nrequire_once __DIR__ . DIRECTORY_SEPARATOR . 'autoload.php';// Use your autoloader or require classes by hand\n\n$db         = new Database(null);\n// With Symfony: EntityManagerInterface $em\n$db-\u003esetConnection($em-\u003egetConnection()-\u003egetNativeConnection());// Wants a PDO connection object class\n```\n\n### Connect with config\n\n```php\n\u003c?php\ndeclare(strict_types = 1);\n\nuse SimplePhpModelSystem\\Database;\n\nrequire_once __DIR__ . DIRECTORY_SEPARATOR . 'autoload.php';// Use your autoloader or require classes by hand\n\n$configFile = __DIR__ . DIRECTORY_SEPARATOR . 'config.php';// Copy config.dist.php and fill the values\n$config     =  require $configFile;\n$db         = new Database($config);\n$db-\u003econnect();// Will throw an exception if not successfull\n```\n\n### Manage models\n\n```php\n\u003c?php\n\nuse examples\\User;\n\n// Without models\n\n$statement = $db-\u003equery(\n    'SELECT 1'\n);\n$this-\u003edata = [];\nwhile (($row = $statement-\u003efetch(PDO::FETCH_ASSOC)) !== false) {\n    $this-\u003edata[] = $row;\n}\nvar_dump($this-\u003edata);\n\n\n// With a model\n\n$user1 = User::create(\n    '5c8169b1-d6ef-4415-8c39-e1664df8b954',\n    'Raven',\n    'Reyes',\n    null\n);\n$user1-\u003esave();// If you forget this line, it will only exist in memory\n$user1 = User::findByUuid('5c8169b1-d6ef-4415-8c39-e1664df8b954');// Find the user back\n$user1-\u003etoArray();\n//[\n//    'user_uuid' =\u003e '5c8169b1-d6ef-4415-8c39-e1664df8b954',\n//    'first_name' =\u003e 'Raven',\n//    'last_name' =\u003e 'Reyes',\n//    'date_of_birth' =\u003e null,\n//]\n$user1-\u003erefresh(); // Get it back from the DB\n$user1-\u003esetLastName('last_name', 'Ali-2');// Change an attribute value (build your own setters using the example)\n$user1-\u003eupdate();// Update it\n$user1-\u003edelete();// Delete it\nUser::deleteAll();// Delete all\n// And more functions, see AbstractModel class\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwdes%2Fsimple-php-model-system","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwdes%2Fsimple-php-model-system","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwdes%2Fsimple-php-model-system/lists"}