{"id":26452122,"url":"https://github.com/fitri-hy/phx","last_synced_at":"2026-04-24T22:32:34.897Z","repository":{"id":281950395,"uuid":"945954526","full_name":"fitri-hy/phx","owner":"fitri-hy","description":"Fast | Secure | Powerful","archived":false,"fork":false,"pushed_at":"2025-03-16T02:02:58.000Z","size":396,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-27T14:03:50.006Z","etag":null,"topics":["mvc-architecture","native","oop","php","php-native","pwa","web"],"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/fitri-hy.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}},"created_at":"2025-03-10T11:42:45.000Z","updated_at":"2025-03-16T02:03:02.000Z","dependencies_parsed_at":"2025-03-18T20:15:16.912Z","dependency_job_id":null,"html_url":"https://github.com/fitri-hy/phx","commit_stats":null,"previous_names":["fitri-hy/phx"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/fitri-hy/phx","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fitri-hy%2Fphx","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fitri-hy%2Fphx/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fitri-hy%2Fphx/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fitri-hy%2Fphx/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fitri-hy","download_url":"https://codeload.github.com/fitri-hy/phx/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fitri-hy%2Fphx/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32243273,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-24T13:21:15.438Z","status":"ssl_error","status_checked_at":"2026-04-24T13:21:15.005Z","response_time":64,"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":["mvc-architecture","native","oop","php","php-native","pwa","web"],"created_at":"2025-03-18T17:26:22.945Z","updated_at":"2026-04-24T22:32:34.892Z","avatar_url":"https://github.com/fitri-hy.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PHX\nFast | Secure | Powerful\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"./public/images/logo/logo.png\" alt=\"Logo\" width=\"200\"\u003e\n\u003c/p\u003e\n\n### Required\n\n- Nodejs\n- Composer\n- PHP 8.0+\n\n### Starter\n\n```\ngit clone https://github.com/fitri-hy/phx.git\ncd phx\nnpm run phx-install\nnpm run phx-start\n\n# Live\nnpm run phx-live\n```\n\n### Folder Structure\n```bash\nphx_framework/  \n│── core/\n│   ├── PHXController.php\n│   ├── PHXDatabase.php\n│   ├── PHXFramework.php\n│   ├── PHXLayout.php\n│   ├── PHXLogger.php\n│   ├── PHXORM.php\n│   └── PHXRouter.php\n│  \n├── public/\n│   ├── css/\n│   ├── images/\n│   ├── js/\n│   ├── .htaccess\n│   ├── index.php\n│   ├── manifest.json\n│   └── service-worker.js\n│  \n├── routes/\n│   ├── api.php\n│   └── web.php\n│  \n├── src/\n│   ├── api/\n│   │   └── Welcome.php\n│   ├── components/\n│   │   └── PWA.php\n│   ├── pages/\n│   │   ├── NotFoundPage.php\n│   │   └── HomePage.php\n│   └── App.php\n│\n├── vendor/\n│\n├── .htaccess\n├── gulpfile.js\n├── composer.json\n├── package.json\n└── README.md\n```\n### Use PHX Markup\n```php\nUSE_PHX_ENGINE=true\n\n# set to false to use html markup\n```\n\n**Example PHX Markup**\n```php\n[!PHX html]\n[html lang:'id']\n[head]\n    [meta charset:'UTF-8']\n    [meta name:'viewport' content:'width:device-width, initial-scale:1.0']\n    [title]Page Title[/title]\n[/head]\n[body id:'main' class:'container']\n    [h1]Hello, World![/h1]\n    [p]This is a basic HTML page.[/p]\n    [a class:'hover?text-green-600' href:'https@google.com']Go to link[/a]\n[/body]\n[/html]\n```\n\n### Use Database\n```php\n\u003c?php\n// import\nuse Core\\PHXDatabase;\n\n// initialization\nPHXDatabase::getInstance();\n```\n\n### Use CSRF Token\n```php\n// Generate\n$csrfToken = $_SESSION['csrf_token'] ?? '';\n\n// in rendering\n[input type:'hidden' name:'csrf_token' value:'\" . $csrfToken . \"']\n```\n\n```php\n// Verification\n\u003c?php\nprivate static function verifyCsrfToken() {\n    return $_SERVER['REQUEST_METHOD'] === 'GET' || ($_SESSION['csrf_token'] ?? '') === ($_POST['csrf_token'] ?? $_SERVER['HTTP_X_CSRF_TOKEN'] ?? '');\n}\n```\n\n### Use Logger\n```php\nuse Core\\PHXLogger;\nPHXLogger::displayError('Error Message');\n```\n\n### Use ORM\n\n| **Method**                      | **Description**                                                                                                                                                             | **Usage Example**                                                                                                                                 |\n|----------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------|\n| `getTableName()`                 | Retrieves the name of the table associated with the current class, based on the class name.                                                                                  | `$model-\u003egetTableName();`                                                                                                                          |\n| `save()`                         | Saves the current data (attributes) to the associated table.                                                                                                               | `$model-\u003esave();`                                                                                                                                 |\n| `all()`                          | Retrieves all records from the associated table.                                                                                                                             | `$model-\u003eall();`                                                                                                                                  |\n| `find($id)`                      | Retrieves a record by its ID.                                                                                                                                                 | `$model-\u003efind(1);`                                                                                                                                 |\n| `setAttributes($attributes)`     | Sets the attributes to be saved or updated in the table.                                                                                                                     | `$model-\u003esetAttributes(['name' =\u003e 'John', 'email' =\u003e 'john@example.com']);`                                                                   |\n| `update($id, $attributes)`       | Updates the record identified by its ID with the specified attributes.                                                                                                       | `$model-\u003eupdate(1, ['name' =\u003e 'John Doe']);`                                                                                                    |\n| `delete($id)`                    | Deletes the record identified by its ID.                                                                                                                                      | `$model-\u003edelete(1);`                                                                                                                             |\n| `where($conditions)`             | Executes a query with a `WHERE` condition (e.g., multiple conditions with `AND`).                                                                                           | `$model-\u003ewhere(['name' =\u003e 'John', 'age' =\u003e 30]);`                                                                                              |\n| `join($table, $onCondition, $type)` | Executes a `JOIN` query with the specified table and on-condition. Optionally supports different join types (`INNER`, `LEFT`, etc.).                                           | `$model-\u003ejoin('posts', 'users.id = posts.user_id', 'INNER');`                                                                                   |\n| `groupBy($columns)`              | Executes a `GROUP BY` query on the specified columns.                                                                                                                        | `$model-\u003egroupBy(['category']);`                                                                                                                 |\n| `having($groupByColumns, $havingConditions)` | Executes a `HAVING` query after a `GROUP BY`, with the specified conditions.                                                                                                   | `$model-\u003ehaving(['category'], ['COUNT(*) \u003e 5']);`                                                                                              |\n| `orderBy($columns, $direction)`  | Executes an `ORDER BY` query on the specified columns, sorting in ascending (`ASC`) or descending (`DESC`) order.                                                           | `$model-\u003eorderBy(['name'], 'ASC');`                                                                                                              |\n| `limit($limit, $offset)`         | Executes a query with a `LIMIT` and `OFFSET` to restrict the number of rows returned.                                                                                       | `$model-\u003elimit(10, 20);`                                                                                                                         |\n| `distinct($columns)`             | Executes a `SELECT DISTINCT` query on the specified columns.                                                                                                                | `$model-\u003edistinct(['name']);`                                                                                                                    |\n| `count($column)`                 | Executes a `COUNT` query to count the number of records, optionally for a specific column.                                                                                   | `$model-\u003ecount();` (counts all rows) or `$model-\u003ecount('name');` (counts distinct values of 'name')                                              |\n| `raw($sql, $params)`             | Executes a raw SQL query with the provided parameters and returns the result.                                                                                               | `$model-\u003eraw('SELECT * FROM users WHERE age \u003e :age', ['age' =\u003e 25]);`                                                                          |\n\n### Example Usage for Common Tasks\n\n```php\n\u003c?php\nnamespace Src\\Pages;\n\nuse Core\\PHXController;\nuse Src\\App;\nuse Core\\PHXORM;\n\nclass Examples {\n  public function GetAll() {\n    return implode('', array_map(fn($fruit) =\u003e\"\n      [li]\n        [span]{$fruit['title']}[/span] \n        [span]{$fruit['price']}[/span]\n      [/li]\n    \", (new class extends PHXORM {\n      protected $table = 'fruits';\n      protected $primaryKey = 'id';\n      protected $attributes = ['title', 'price'];\n    })-\u003eGetAll()));\n  }\n  public function index() {\n    $fruitList = $this-\u003eGetAll();\n    PHXController::render(\"\n      [div]\n        $fruitList\n      [/div]\n    \");\n  }\n}\n```\n\n**Insert New Record**:  \n  ```php\n  $user = new User();\n  $user-\u003esetAttributes(['name' =\u003e 'John Doe', 'email' =\u003e 'john@example.com']);\n  $user-\u003esave();\n  ```\n\n**Fetch All Records**:  \n  ```php\n  $users = $user-\u003eall();\n  ```\n\n**Find a Record by ID**:  \n  ```php\n  $user = $user-\u003efind(1);\n  ```\n\n**Update a Record**:  \n  ```php\n  $user-\u003eupdate(1, ['name' =\u003e 'John Doe Updated']);\n  ```\n\n**Delete a Record**:  \n  ```php\n  $user-\u003edelete(1);\n  ```\n\n**Run a Custom Query with WHERE**:  \n  ```php\n  $users = $user-\u003ewhere(['name' =\u003e 'John', 'age' =\u003e 30]);\n  ```\n\n**Run a JOIN Query**:  \n  ```php\n  $usersWithPosts = $user-\u003ejoin('posts', 'users.id = posts.user_id', 'LEFT');\n  ```\n\n**Group by Column**:  \n  ```php\n  $groupedUsers = $user-\u003egroupBy(['age']);\n  ```\n\n**Count Records**:  \n  ```php\n  $userCount = $user-\u003ecount();\n  ```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffitri-hy%2Fphx","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffitri-hy%2Fphx","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffitri-hy%2Fphx/lists"}