{"id":21042685,"url":"https://github.com/yugabytedb-samples/yugabyte-simple-php-app","last_synced_at":"2025-03-13T21:43:06.262Z","repository":{"id":69256339,"uuid":"459741146","full_name":"YugabyteDB-Samples/yugabyte-simple-php-app","owner":"YugabyteDB-Samples","description":"A simple PHP application that connects to a YugabyteDB database cluster and performs basic CRUD operations.","archived":false,"fork":false,"pushed_at":"2024-07-16T16:35:27.000Z","size":198,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-28T14:06:31.223Z","etag":null,"topics":["demos","php","yugabytedb"],"latest_commit_sha":null,"homepage":"","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/YugabyteDB-Samples.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}},"created_at":"2022-02-15T20:36:31.000Z","updated_at":"2024-07-16T16:35:31.000Z","dependencies_parsed_at":null,"dependency_job_id":"29da2480-ba92-45bb-af5e-cb59fbdf36bc","html_url":"https://github.com/YugabyteDB-Samples/yugabyte-simple-php-app","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/YugabyteDB-Samples%2Fyugabyte-simple-php-app","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/YugabyteDB-Samples%2Fyugabyte-simple-php-app/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/YugabyteDB-Samples%2Fyugabyte-simple-php-app/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/YugabyteDB-Samples%2Fyugabyte-simple-php-app/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/YugabyteDB-Samples","download_url":"https://codeload.github.com/YugabyteDB-Samples/yugabyte-simple-php-app/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243489780,"owners_count":20298997,"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":["demos","php","yugabytedb"],"created_at":"2024-11-19T14:08:40.719Z","updated_at":"2025-03-13T21:43:06.236Z","avatar_url":"https://github.com/YugabyteDB-Samples.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Simple PHP Application for YugabyteDB\n\nThis application connects to your YugabyteDB instance via the \n[php-pgsql](https://www.php.net/manual/en/book.pgsql.php) driver for PostgreSQL and performs basic SQL operations. The instructions below are provided for [YugabyteDB Aeon](https://cloud.yugabyte.com/) deployments. \nIf you use a different type of deployment, then update the `sample-app.php` file with proper connection parameters.\n\n## Prerequisite\n\n* PHP runtime - the sample project was created with PHP 8.1 but should work with earlier and later versions.\n* Command line tool or your favorite IDE, such as Visual Studio Code.\n\n## Start YugabyteDB Aeon Cluster\n\n* [Start YugabyteDB Aeon](https://docs.yugabyte.com/latest/yugabyte-cloud/cloud-quickstart/qs-add/) instance. You can use\nthe free tier at no cost.\n* Add an IP address of your machine/laptop to the [IP allow list](https://docs.yugabyte.com/latest/yugabyte-cloud/cloud-secure-clusters/add-connections/#manage-ip-allow-lists)\n\n## Clone Application Repository\n\nClone the repository and change dirs into it:\n\n```bash\ngit clone https://github.com/YugabyteDB-Samples/yugabyte-simple-php-app.git \u0026\u0026 cd yugabyte-simple-php-app\n```\n\n## Provide YugabyteDB Aeon Connection Parameters\n\nSet the following connection parameters in the `sample-app.php` file:\n* `HOST` - the hostname of your YugabyteDB Managed instance.\n* `USER` - the username for your database.\n* `PASSWORD` - the password for your database.\n* `SSL_MODE`  - an SSL mode. Make sure it's set to `verify-full` for YugabyteDB Aeon.\n* `SSL_ROOT_CERT` - a full path to your CA root cert (for example, `/Users/dmagda/certificates/root.crt`). \n\nNote, you can easily find all the settings on the YugabyteDB Aeon dashboard:\n\n![image](resources/cloud_app_settings.png)\n\n## Run the Application\n \n1. Install the [php-pgsql](https://www.php.net/manual/en/book.pgsql.php) driver:\n    * Homebrew users of version PHP 7.2+: the driver is installed automatically with the `brew install php` command.\n    * Ubuntu users can install with the `sudo apt-get install php-pgsql` command.\n    * CentOS users can install with the `sudo yum install php-pgsql` command.\n    * Others need to follow the [php-pgsql installation guide](https://www.php.net/manual/en/pgsql.setup.php).\n\n3. Run the application:\n    ```bash\n    php sample-app.php\n    ```\n\nUpon successful execution, you will see output similar to the following:\n\n```bash\n\u003e\u003e\u003e\u003e Connecting to YugabyteDB!\n\u003e\u003e\u003e\u003e Successfully connected to YugabyteDB!\n\u003e\u003e\u003e\u003e Successfully created table DemoAccount.\n\u003e\u003e\u003e\u003e Selecting accounts:\nname=Jessica, age=28, country=USA, balance=10000\nname=John, age=28, country=Canada, balance=9000\n\u003e\u003e\u003e\u003e Transferred 800 between accounts\n\u003e\u003e\u003e\u003e Selecting accounts:\nname=Jessica, age=28, country=USA, balance=9200\nname=John, age=28, country=Canada, balance=9800\n```\n\n## Explore Application Logic\n\nCongrats! You've successfully executed a simple PHP app that works with YugabyteDB Aeon.\n\nNow, explore the source code of `sample-app.php`:\n1. `connect` function - establishes a connection with your cloud instance via the php-pgsql driver.\n3. `create_database` function - creates a table and populates it with sample data.\n4. `select_accounts` function - queries the data with SQL `SELECT` statements.\n5. `transfer_money_between_accounts` function - updates records consistently with distributed transactions.\n\n## Questions or Issues?\n\nHaving issues running this application or want to learn more from Yugabyte experts?\n\nJoin [our Slack channel](https://communityinviter.com/apps/yugabyte-db/register),\nor raise a question on StackOverflow and tag the question with `yugabytedb`!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyugabytedb-samples%2Fyugabyte-simple-php-app","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyugabytedb-samples%2Fyugabyte-simple-php-app","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyugabytedb-samples%2Fyugabyte-simple-php-app/lists"}