{"id":15307890,"url":"https://github.com/alextselegidis/phingle","last_synced_at":"2025-04-14T23:32:02.713Z","repository":{"id":86292867,"uuid":"452667557","full_name":"alextselegidis/phingle","owner":"alextselegidis","description":"📄 Single File App Template","archived":false,"fork":false,"pushed_at":"2024-05-30T18:53:45.000Z","size":282,"stargazers_count":29,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-03-28T12:21:13.471Z","etag":null,"topics":["php","single-file-app","template"],"latest_commit_sha":null,"homepage":"https://github.com/alextselegidis/phingle","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/alextselegidis.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-01-27T12:08:03.000Z","updated_at":"2025-03-18T08:47:14.000Z","dependencies_parsed_at":"2023-03-13T09:30:26.041Z","dependency_job_id":"6cd7e2b3-540b-487e-98bc-ea05e0a90270","html_url":"https://github.com/alextselegidis/phingle","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/alextselegidis%2Fphingle","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alextselegidis%2Fphingle/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alextselegidis%2Fphingle/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alextselegidis%2Fphingle/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alextselegidis","download_url":"https://codeload.github.com/alextselegidis/phingle/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248978952,"owners_count":21192879,"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":["php","single-file-app","template"],"created_at":"2024-10-01T08:12:44.581Z","updated_at":"2025-04-14T23:32:02.405Z","avatar_url":"https://github.com/alextselegidis.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003e\n    \u003cbr\u003e\n    \u003ca href=\"https://easyappointments.org\"\u003e\n        \u003cimg src=\"https://raw.githubusercontent.com/alextselegidis/phingle/main/logo.png\" alt=\"Phingle\" width=\"150\"\u003e\n    \u003c/a\u003e\n    \u003cbr\u003e\n    Phingle\n    \u003cbr\u003e\n\u003c/h1\u003e\n\n\u003cbr\u003e\n\n\u003ch4 align=\"center\"\u003e\n    Single File App Template\n\u003c/h4\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"#about\"\u003eAbout\u003c/a\u003e •\n  \u003ca href=\"#features\"\u003eStructure\u003c/a\u003e •\n  \u003ca href=\"#setup\"\u003eDevelop\u003c/a\u003e •\n  \u003ca href=\"#license\"\u003eLicense\u003c/a\u003e\n\u003c/p\u003e\n\n![screenshot](phingle-snippet.png)\n\n## About\n\n**Phingle** is a simple yet practical single file app template file, that will allow to quickly implement utility \nscripts for your server. It was created as a started point for very basic server side operations both locally or on \nremote servers, as it aims to provide lightweight routing functionality and CDN based styling with Bootstrap. \n**Attention: this is just a file template and no framework by any means.** You can copy it and create your own single\n(or even multiple) file scripts with PHP. \n\n## Features\n\nThe file is designed to be as lightweight and easy to work with as possible. \n\n* Application Class (Common Logic)\n* Simple Routing\n* Bootstrap Styling (CDN)\n* Single File App\n\n## Develop\n\nBy default, Phingle has no 3rd party dependencies (although you could add some if needed) and you can directly start by \ncloning this repository and copying the `phingle.php` file template, before you start to add your own custom \nfunctionality.\n\n```php\n$app-\u003eroute('default', function () {\n\t$this-\u003erender('\u003ch1\u003eHello World\u003c/h1\u003e');\n});\n```\n\n### Routing\n\nTowards the bottom of the file, you will find a section where you can add your own custom callbacks and render HTML or \nprocess form submissions. For a request to route to your custom callback, you just need to provide the `action` \nparameter, either with a `GET` or `POST` request. \n\n```php\n$app-\u003eroute('default', function () {\n\t$content = \u003c\u003c\u003cHTML\n        \u003cdiv\u003e\n            \u003ch1\u003eDefault Page\u003c/h1\u003e\n            \n            \u003ca href=\"?action=second-page\" class=\"btn btn-primary\"\u003e\n                Go To Second Page\n            \u003c/a\u003e\n        \u003c/div\u003e\nHTML;\n\n\t$this-\u003erender($content);\n});\n\n$app-\u003eroute('second-page', function () {\n\t$content = \u003c\u003c\u003cHTML\n        \u003cdiv\u003e\n            \u003ch1\u003eSecond Page\u003c/h1\u003e\n            \n            \u003ca href=\"?action=default\" class=\"btn btn-primary\"\u003e\n                Go To Default Page\n            \u003c/a\u003e\n        \u003c/div\u003e\nHTML;\n\n\t$this-\u003erender($content);\n});\n```\n\n### Form Submission\n\nIn the same way, you can include forms in your HTML mark up and add some server side request handling for them, by \nutilizing the `action` parameter.\n\n```php\n$app-\u003eroute('default', function () {\n\t$content = \u003c\u003c\u003cHTML\n        \u003cdiv\u003e\n            \u003ch1\u003eDefault Page\u003c/h1\u003e\n            \n            \u003cform action=\"?action=submission-callback\" method=\"post\"\u003e\n                \u003cdiv class=\"mb-3\"\u003e\n                    \u003clabel for=\"name\" class=\"form-label\"\u003eName\u003c/label\u003e\n                    \u003cinput type=\"text\" name=\"name\" id=\"name\" class=\"form-control\" required /\u003e\n                \u003c/div\u003e\n                \n                \u003cbutton type=\"submit\" class=\"btn btn-primary\"\u003e\n                    Submit    \n                \u003c/button\u003e\n            \u003c/form\u003e\n        \u003c/div\u003e\nHTML;\n\n\t$this-\u003erender($content);\n});\n\n$app-\u003eroute('submission-callback', function () {\n    $name = $_POST['name'] ?? null;\n    \n    if ( ! $name) {\n        die('No name POST parameter was provided.'); \n    }\n\n\t$content = \u003c\u003c\u003cHTML\n        \u003cdiv\u003e\n            \u003ch1\u003eHello {$name}!\u003c/h1\u003e\n            \n            \u003ca href=\"?action=default\" class=\"btn btn-primary\"\u003e\n                Go To Default Page\n            \u003c/a\u003e\n        \u003c/div\u003e\nHTML;\n\n\t$this-\u003erender($content);\n});\n```\n\n### Enable Authentication\n\nYou can easily protect the script with the built-in HTTP Basic Authentication. \n\nAt the top of your Phingle file, you will find the following section: \n\n```php\nconst AUTH_USERNAME = 'administrator';\n\nconst AUTH_PASSWORD = ''; // Set a password to enable HTTP Basic Auth.\n```\n\nChange the username and set a password accordingly, so that the file requires the credentials before being executed on \nthe server.\n\n\n## License\n\nCode Licensed Under [GPL v3.0](https://www.gnu.org/licenses/gpl-3.0.en.html) | Content Under [CC BY 3.0](https://creativecommons.org/licenses/by/3.0/)\n\n---\n\nWebsite [alextselegidis.com](https://alextselegidis.com) \u0026nbsp;\u0026middot;\u0026nbsp;\nGitHub [alextselegidis](https://github.com/alextselegidis) \u0026nbsp;\u0026middot;\u0026nbsp;\nTwitter [@alextselegidis](https://twitter.com/AlexTselegidis)\n\n###### More Projects On Github\n###### ⇾ [Plainpad \u0026middot; Self Hosted Note Taking App](https://github.com/alextselegidis/plainpad)\n###### ⇾ [Questionful \u0026middot; Web Questionnaires Made Easy](https://github.com/alextselegidis/questionful)\n###### ⇾ [Integravy \u0026middot; Service Orchestration At Your Fingertips](https://github.com/alextselegidis/integravy)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falextselegidis%2Fphingle","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falextselegidis%2Fphingle","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falextselegidis%2Fphingle/lists"}