{"id":26053449,"url":"https://github.com/fitri-hy/php-native","last_synced_at":"2026-05-30T04:31:30.174Z","repository":{"id":280963710,"uuid":"943757519","full_name":"fitri-hy/php-native","owner":"fitri-hy","description":"Keep it simple and fast. Build scalable applications with a lightweight PHP framework that’s purely native, with no extra overhead.","archived":false,"fork":false,"pushed_at":"2025-03-08T06:13:19.000Z","size":1276,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-12-25T16:16:04.241Z","etag":null,"topics":["framework","mvc","native","php"],"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}},"created_at":"2025-03-06T08:09:58.000Z","updated_at":"2025-03-08T06:13:22.000Z","dependencies_parsed_at":"2025-03-06T09:29:55.302Z","dependency_job_id":"3d619225-ac53-47ec-9037-1083048821af","html_url":"https://github.com/fitri-hy/php-native","commit_stats":null,"previous_names":["fitri-hy/php-native"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/fitri-hy/php-native","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fitri-hy%2Fphp-native","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fitri-hy%2Fphp-native/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fitri-hy%2Fphp-native/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fitri-hy%2Fphp-native/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fitri-hy","download_url":"https://codeload.github.com/fitri-hy/php-native/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fitri-hy%2Fphp-native/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33680522,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-05-30T02:00:06.278Z","response_time":92,"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":["framework","mvc","native","php"],"created_at":"2025-03-08T07:28:30.912Z","updated_at":"2026-05-30T04:31:30.158Z","avatar_url":"https://github.com/fitri-hy.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PHP-Native\n\nKeep it simple and fast. Build scalable applications with a lightweight PHP framework that’s purely native, with no extra overhead. \n\n### Getting Variants\n\n```bash\nnpx create-php-native\n```\n\n\u003cimg src=\"./public/images/ss.png\" /\u003e\n\n### Folder Structure\n\n```bash\nphp/\n│── app/\n│   ├── Controllers/\n│   │    ├── Api/\n│   │    │    ├── WelcomeController.php\n│   │    ├── Error404Controller.php\n│   │    ├── ErrorController.php\n│   │    ├── HomeController.php\n│   │\n│   ├── Middleware/\n│   │    ├── ApiKeyMiddleware.php\n│   │\n│   ├── Models/\n│   │    ├── ExampleData.php\n│   │\n│   ├── Routes/\n│   │    ├── web.php\n│   │    ├── api.php\n│   │\n│   ├── Views/\n│        ├── layouts/\n│        │    ├── main.php\n│        ├── partials/\n│        │    ├── header.php\n│        │    ├── footer.php\n│        ├── pages/\n│             ├── 404.php\n│             ├── error.php\n│             ├── home.php\n│── config/\n│   ├── config.php\n│\n│── core/\n│   ├── Controller.php\n│   ├── Cors.php\n│   ├── Database.php\n│   ├── Model.php\n│   ├── Router.php\n│   ├── Security.php\n│\n│── public/\n│   ├── images/\n│   ├── css/\n│   ├── js/\n│   ├── .htaccess\n│   ├── index.php\n│\n│── vendor/\n│\n│── .env \n│── .htaccess\n│── composer.json\n│── README.md\n```\n\n### Example Get Data\n\n```php\n// Display data\nuse Core\\Database;\n\npublic function Example() {\n  $data = Database::fetchAll(\"SELECT * FROM table_name\");\n  return $this-\u003eview('pages/home', \n  [\n    'data' =\u003e $data, \n    'title' =\u003e 'Example Pages'\n  ]);\n}\n```\n\n### Example Get By ID Data\n\n```php\nuse Core\\Database;\n\npublic function example($id) {\n  $data = Database::fetch(\"SELECT * FROM table_name WHERE id = :id\", ['id' =\u003e $id]);\n  if (!$data) {\n    header(\"Location: /error\");\n    exit;\n  }\n  return $this-\u003eview('pages/home', [\n    'data' =\u003e $data,\n    'title' =\u003e 'Example Page'\n  ]);\n}\n```\n\n### Example Adding Data\n\n```php\nuse Core\\Database;\n\npublic function Example() {\n  if ($_SERVER['REQUEST_METHOD'] === 'POST' \u0026\u0026 !empty($_POST['form_column_name'])) {\n    Database::execute(\"INSERT INTO table_name (column_name) VALUES (:column_name)\", \n    [\n    'column_name' =\u003e htmlspecialchars(trim($_POST['form_column_name']))\n    ]);\n  }\n  header(\"Location: /\");\n  exit;\n}\n```\n\n### Example Edit Data\n\n```php\nuse Core\\Database;\n\npublic function update($id) {\n  if ($_SERVER['REQUEST_METHOD'] !== 'POST') {\n    return;\n  }\n  Database::execute(\"UPDATE table_name SET column_name = :column_name WHERE id = :id\", \n  [\n    'column_name' =\u003e htmlspecialchars(trim($_POST['form_column_name'])),\n    'id' =\u003e $id\n  ]);\n  header(\"Location: /\");\n  exit;\n}\n```\n\n### Example Delete Data\n\n```php\nuse Core\\Database;\n\npublic function delete($id) {\n  Database::execute(\"DELETE FROM table_name WHERE id = :id\", ['id' =\u003e $id]);\n  header(\"Location: /\");\n  exit;\n}\n```\n\n### Generate \u0026 Verification CSRF Input (View)\n\n```php\n// Generate in Form\n\u003c?php use Core\\Security; ?\u003e\n...\n\u003cinput type=\"hidden\" name=\"csrf_token\" value=\"\u003c?= Security::generateCsrfToken() ?\u003e\"\u003e\n...\n\n// Verification in Controller\nuse Core\\Security;\n...\nif ($_SERVER[\"REQUEST_METHOD\"] !== \"POST\" || !Security::verifyCsrfToken($_POST['csrf_token'] ?? '')) {\n  $_SESSION['error'] = \"Invalid CSRF Token!\";\n  header(\"Location: /error\");\n  exit;\n}\n...\n```\n\n### Enable Secure Input (Controller)\n\n```php\nuse Core\\Security;\n...\n'column_name' =\u003e trim(Security::sanitize($_POST['form_column_name'])),\n...\n```\n\n### Disable display layout, add 'false' to disable layout usage\n\n```php\nreturn $this-\u003eview('pages/home', \n  [\n    'title' =\u003e 'Home'\n  ], false);\n```\n\n### Set up a database connection in /config/config.php\n\n```php\n'db' =\u003e [\n  'host' =\u003e 'localhost',\n  'dbname' =\u003e 'demo',\n  'user' =\u003e 'root',\n  'pass' =\u003e ''\n],\n```\n\n### Change api key (http://localhost:8000/v1?api-key=) in /config/config.php\n\n```php\n'api' =\u003e [\n  'api_key' =\u003e 'example-api-key-here',\n]\n```\n\n### Manage Additional Security in /config/config.php\n\n```php\n'security' =\u003e [\n  'csrf_protection' =\u003e true,\n  'session_security' =\u003e true,\n  'rate_limiting' =\u003e true,\n  'security_headers' =\u003e true,\n  'headers' =\u003e [\n    'X-Frame-Options'            =\u003e 'DENY',\n    'X-XSS-Protection'           =\u003e '1; mode=block',\n    'X-Content-Type-Options'     =\u003e 'nosniff',\n    'Referrer-Policy'            =\u003e 'no-referrer-when-downgrade',\n    'Strict-Transport-Security'  =\u003e 'max-age=31536000; includeSubDomains; preload',\n  ],\n],\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffitri-hy%2Fphp-native","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffitri-hy%2Fphp-native","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffitri-hy%2Fphp-native/lists"}