{"id":26140925,"url":"https://github.com/undecaf/doctrine-file-storage","last_synced_at":"2025-03-11T02:58:27.927Z","repository":{"id":56099868,"uuid":"271517394","full_name":"undecaf/doctrine-file-storage","owner":"undecaf","description":"Storing files as BLOBs with Doctrine ORM","archived":false,"fork":false,"pushed_at":"2024-11-24T09:53:39.000Z","size":97,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-11-24T10:28:55.694Z","etag":null,"topics":["blob","doctrine-orm","fluid-template-engine","imagick","php7"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/undecaf.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}},"created_at":"2020-06-11T10:27:43.000Z","updated_at":"2024-11-24T09:53:36.000Z","dependencies_parsed_at":"2022-08-15T13:10:29.098Z","dependency_job_id":null,"html_url":"https://github.com/undecaf/doctrine-file-storage","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/undecaf%2Fdoctrine-file-storage","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/undecaf%2Fdoctrine-file-storage/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/undecaf%2Fdoctrine-file-storage/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/undecaf%2Fdoctrine-file-storage/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/undecaf","download_url":"https://codeload.github.com/undecaf/doctrine-file-storage/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242961706,"owners_count":20213316,"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","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":["blob","doctrine-orm","fluid-template-engine","imagick","php7"],"created_at":"2025-03-11T02:58:27.289Z","updated_at":"2025-03-11T02:58:27.917Z","avatar_url":"https://github.com/undecaf.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Storing files as BLOBs with Doctrine ORM\n\nPHP applications usually store uploaded files in the server's file system and persist\nonly the file paths in a database.\nObtaining a consistent backup of such a dataset may be difficult.\n\nThis sample project uses Doctrine ORM to store uploaded files as BLOBs in a database.\nAfter all, MySQL supports 4GB BLOBs and PostgreSQL even 4TB BLOBs.\n\nIn Doctrine ORM, however, `msqli`, `pdo_mysql` and `pdo_pgsql` do not stream into/from a BLOB\nbut materialize the BLOB in memory in its entirety.\n\nTherefore, the file size for BLOB storage is limited by the PHP `memory_limit` (128MB by default),\nand for MySQL also by the `max_allowed_packet` parameter. In order to stay within these\nlimits, the PHP `upload_max_filesize` should be set accordingly.\n\nDespite these drawbacks, using BLOBs can be advantageous since this keeps the complete dataset\nin a single place (the database);\nthis provides for consistent backups and synchronization in a database cluster.\n\nWithin this project, a few additional techniques are mentioned that might be useful. \n\n### Subjects\n\n- Uploading files and storing them as\n  [BLOBs](https://en.wikipedia.org/wiki/Binary_large_object) with [Doctrine ORM](https://www.doctrine-project.org/)\n- Serving and downloading uploaded files\n- Hiding primary keys from clients and identifying file entities by\n  [UUID](https://en.wikipedia.org/wiki/Universally_unique_identifier)\n- Using a\n  [mapped superclass](https://www.doctrine-project.org/projects/doctrine-mongodb-odm/en/latest/reference/inheritance-mapping.html#mapped-superclasses)\n  as base class for entity classes\n- Applying\n  [collection per class inheritance](https://www.doctrine-project.org/projects/doctrine-mongodb-odm/en/latest/reference/inheritance-mapping.html#collection-per-class-inheritance)\n  to derive specialized file entities (such as image entities)\n- Generating image thumbnails with the\n  [Imagick PHP extension](https://www.php.net/manual/en/class.imagick.php)\n- Rendering a UI with the [Fluid Template Engine](https://typo3.org/fluid)\n- Unit testing Doctrine ORM entity classes with [PHPUnit](https://phpunit.de/)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fundecaf%2Fdoctrine-file-storage","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fundecaf%2Fdoctrine-file-storage","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fundecaf%2Fdoctrine-file-storage/lists"}