{"id":18036604,"url":"https://github.com/codexshaper/php-database","last_synced_at":"2025-04-05T00:14:10.393Z","repository":{"id":56955864,"uuid":"269548874","full_name":"Codexshaper/php-database","owner":"Codexshaper","description":"Laravel database and eloquent for php project.","archived":false,"fork":false,"pushed_at":"2020-06-05T07:24:51.000Z","size":10,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-25T05:02:20.457Z","etag":null,"topics":["database","eloquent","migration","orm","php"],"latest_commit_sha":null,"homepage":null,"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/Codexshaper.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-05T06:31:49.000Z","updated_at":"2020-06-05T08:03:22.000Z","dependencies_parsed_at":"2022-08-21T08:50:39.977Z","dependency_job_id":null,"html_url":"https://github.com/Codexshaper/php-database","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Codexshaper%2Fphp-database","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Codexshaper%2Fphp-database/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Codexshaper%2Fphp-database/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Codexshaper%2Fphp-database/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Codexshaper","download_url":"https://codeload.github.com/Codexshaper/php-database/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247266566,"owners_count":20910836,"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":["database","eloquent","migration","orm","php"],"created_at":"2024-10-30T12:13:44.362Z","updated_at":"2025-04-05T00:14:10.373Z","avatar_url":"https://github.com/Codexshaper.png","language":"PHP","readme":"[![License](http://img.shields.io/:license-mit-blue.svg?style=flat-square)](http://badges.mit-license.org)\n[![Build Status](https://travis-ci.org/Codexshaper/php-database.svg?branch=master)](https://travis-ci.org/Codexshaper/php-database)\n[![StyleCI](https://github.styleci.io/repos/269548874/shield?branch=master)](https://github.styleci.io/repos/269548874)\n[![Quality Score](https://img.shields.io/scrutinizer/g/Codexshaper/php-database.svg?style=flat-square)](https://scrutinizer-ci.com/g/Codexshaper/php-database)\n[![Downloads](https://poser.pugx.org/Codexshaper/php-database/d/total.svg)](https://packagist.org/packages/Codexshaper/php-database)\n[![Latest Version on Packagist](https://img.shields.io/packagist/v/Codexshaper/php-database.svg?style=flat-square)](https://packagist.org/packages/Codexshaper/php-database)\n\n# Database and ORM\nLaravel database and eloquent for php project.\n\n## Download\n\n```\ncomposer require codexshaper/php-database\n```\n\n## Setup root facade\n\n```\nuse Illuminate\\Support\\Facades\\Facade;\nuse Illuminate\\Container\\Container;\n\nFacade::setFacadeApplication(new Container);\n```\n\nNote: If you alraedy setup `container` as a root facade then leave it.\n\n## Create a new connection\n```\nuse CodexShaper\\Database\\Database;\n```\n### Using `constructor`\n```\n$db = new Database([\n\t\"driver\" \t\t=\u003e \"mysql\",\n\t\"host\" \t\t\t=\u003e 'localhost',\n\t\"database\" \t\t=\u003e 'db_name',\n\t\"username\" \t\t=\u003e 'db_user',\n\t\"password\" \t\t=\u003e 'db_password',\n\t\"prefix\"   \t\t=\u003e 'db_prefix',\n\t\"charset\"   \t=\u003e 'utf8mb4',\n\t\"collation\"   \t=\u003e 'utf8mb4_unicode_ci',\n]);\n```\n### Using `addConnection` method\n\n```\n$db = new Database;\n$db-\u003eaddConnection([\n\t\"driver\" \t\t=\u003e \"mysql\",\n\t\"host\" \t\t\t=\u003e 'localhost',\n\t\"database\" \t\t=\u003e 'laravel-woocommerce',\n\t\"username\" \t\t=\u003e 'root',\n\t\"password\" \t\t=\u003e '',\n\t\"prefix\"   \t\t=\u003e 'wp_',\n\t\"charset\"   \t=\u003e 'utf8mb4',\n\t\"collation\"   \t=\u003e 'utf8mb4_unicode_ci',\n]);\n```\n\n## Finaly `run` database to use globally and setup eloquent orm\n\n```\n$db-\u003erun();\n```\n\n## Create a table\n\n```\nuse CodexShaper\\Database\\Facades\\Schema;\nuse Illuminate\\Database\\Schema\\Blueprint;\n\nSchema::create('users', function (Blueprint $table) {\n    $table-\u003eid();\n    $table-\u003estring('name');\n    $table-\u003estring('email')-\u003eunique();\n    $table-\u003etimestamp('email_verified_at')-\u003enullable();\n    $table-\u003estring('password');\n    $table-\u003erememberToken();\n    $table-\u003etimestamps();\n});\n```\n\n## Drop a table\n\n```\nuse CodexShaper\\Database\\Facades\\Schema;\nSchema::dropIfExists('custom_options');\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodexshaper%2Fphp-database","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcodexshaper%2Fphp-database","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodexshaper%2Fphp-database/lists"}