{"id":26530086,"url":"https://github.com/plasmaphp/schemas","last_synced_at":"2025-08-18T21:14:08.725Z","repository":{"id":54151216,"uuid":"162807056","full_name":"PlasmaPHP/schemas","owner":"PlasmaPHP","description":"Schemas map any data source into a PHP object.","archived":false,"fork":false,"pushed_at":"2021-10-09T17:12:38.000Z","size":416,"stargazers_count":2,"open_issues_count":0,"forks_count":2,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-08-16T15:39:09.895Z","etag":null,"topics":["databse","php","php-library","php7","plasma","schemas"],"latest_commit_sha":null,"homepage":"https://plasmaphp.github.io/schemas/","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/PlasmaPHP.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-12-22T11:51:47.000Z","updated_at":"2022-02-12T13:58:58.000Z","dependencies_parsed_at":"2022-08-13T07:40:43.417Z","dependency_job_id":null,"html_url":"https://github.com/PlasmaPHP/schemas","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/PlasmaPHP/schemas","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PlasmaPHP%2Fschemas","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PlasmaPHP%2Fschemas/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PlasmaPHP%2Fschemas/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PlasmaPHP%2Fschemas/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PlasmaPHP","download_url":"https://codeload.github.com/PlasmaPHP/schemas/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PlasmaPHP%2Fschemas/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271061334,"owners_count":24692509,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-18T02:00:08.743Z","response_time":89,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["databse","php","php-library","php7","plasma","schemas"],"created_at":"2025-03-21T17:29:31.446Z","updated_at":"2025-08-18T21:14:08.431Z","avatar_url":"https://github.com/PlasmaPHP.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Schemas [![CI status](https://github.com/PlasmaPHP/schemas/workflows/CI/badge.svg)](https://github.com/PlasmaPHP/schemas/actions)\n\nSchemas is a simple Object Relational Mapper (ORM) for Plasma. Schemas maps any data source into a PHP object.\n\n# Getting Started\nSchemas can be installed through composer.\n\n```\ncomposer require plasma/schemas\n```\n\nYou first need to create a Plasma client and then create a `Repository` (which acts like a client) with the created client.\nThen you need to create your schema classes and the directory for these schema classes. You will need to register these directories to the Repository.\n\nDirectories build schemas from query results and interface with the repository for queries.\n\nAfter that, each call onto the Repository `query` or `execute` methods will give you a dedicated `SchemaCollection` with the `Schema` instances.\nA call to `Repository::prepare` will give you, if successful, a wrapped `Statement` instance. The wrapper has the same purpose as the `Repository`.\n\n```php\n$loop = \\React\\EventLoop\\Factory::create();\n$factory = new \\Plasma\\Drivers\\MySQL\\DriverFactory($loop, array());\n\n$client = \\Plasma\\Client::create($factory, 'root:1234@localhost');\n$repository = new \\Plasma\\Schemas\\Repository($client);\n\n/**\n * Our example table \"users\" consists of two columns:\n * - id ; auto incremented integer (length 12) primary\n * - name ; varchar(255) utf8mb4_generl_ci\n */\nclass Users extends \\Plasma\\Schemas\\AbstractSchema {\n    public $id;\n    public $name;\n    \n    /**\n     * Returns the schema definition.\n     * @return \\Plasma\\Schemas\\ColumnDefinitionInterface[]\n     */\n    static function getDefinition(): array {\n        return array(\n            // A generic column definition builder\n            // solely for ease of use and does not\n            // have to be used.\n            // Any Plasma Column Definition\n            // can be used.\n            \n            static::getColDefBuilder()\n                -\u003ename('id')\n                -\u003etype('INTEGER')\n                -\u003elength(12)\n                -\u003eautoIncrement()\n                -\u003eprimary()\n                -\u003egetDefinition(),\n            static::getColDefBuilder()\n                -\u003ename('name')\n                -\u003etype('VARCHAR')\n                -\u003elength(255)\n                -\u003egetDefinition()\n        );\n    }\n    \n    /**\n     * Returns the name of the table.\n     * @return string\n     */\n    static function getTableName(): string {\n        return 'users';\n    }\n    \n    /**\n     * Returns the name of the identifier column (primary or unique), or null.\n     * @return string|null\n     */\n    static function getIdentifierColumn(): ?string {\n        return 'id';\n    }\n}\n\n// null is the SQL grammar (see plasma/sql-common)\n$builderA = new \\Plasma\\Schemas\\SQLDirectory(Users::class, null);\n$repository-\u003eregisterDirectory('users', $builderA);\n\n$repository-\u003eexecute('SELECT * FROM `users`', array())\n    -\u003edone(function (\\Plasma\\Schemas\\SchemaCollection $collection) {\n        // Do something with the collection\n    });\n\n$loop-\u003erun();\n```\n\n# Preloads\nSchemas has a mechanism called Preloads.\n\nPreloads are a way to load foreign references at the same time as a schema gets loaded, and let your schema be always filled with the foreign reference schema.\nHow the preloads are exactly loaded depends on the Directory implementation.\n\nPreloads are foreign targets with fetch mode `ALWAYS` and are automatically handled.\nForeign target with fetch mode `LAZY` are not automatically loaded and need to be explicitely asked for by calling `resolveForeignTargets` on the schema.\n\nWhether one uses one over the other fetch mode depends on the use case. It makes sense to only preload schemas you actually really always need.\n\nPreloads are supported through the `ColumnDefinitionInterface`. Current implementations are the `ColumnDefinition` implementation and the `ColumnDefinitionBuilder`.\n\n# Documentation\nhttps://plasmaphp.github.io/schemas/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fplasmaphp%2Fschemas","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fplasmaphp%2Fschemas","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fplasmaphp%2Fschemas/lists"}