{"id":19985889,"url":"https://github.com/aeberdinelli/learning-php","last_synced_at":"2025-03-01T20:26:16.192Z","repository":{"id":144044991,"uuid":"77109540","full_name":"aeberdinelli/learning-php","owner":"aeberdinelli","description":"This is something I wrote many years ago before learning ZF or any other framework. Contains a template, plugins and language system built from scratch.","archived":false,"fork":false,"pushed_at":"2021-06-09T11:30:04.000Z","size":22,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-12T11:30:54.050Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/aeberdinelli.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2016-12-22T03:41:42.000Z","updated_at":"2021-06-09T11:30:07.000Z","dependencies_parsed_at":"2023-04-22T14:35:01.089Z","dependency_job_id":null,"html_url":"https://github.com/aeberdinelli/learning-php","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/aeberdinelli%2Flearning-php","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aeberdinelli%2Flearning-php/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aeberdinelli%2Flearning-php/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aeberdinelli%2Flearning-php/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aeberdinelli","download_url":"https://codeload.github.com/aeberdinelli/learning-php/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241419698,"owners_count":19959963,"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":[],"created_at":"2024-11-13T04:26:43.079Z","updated_at":"2025-03-01T20:26:16.170Z","avatar_url":"https://github.com/aeberdinelli.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# A library with all that you need\nThis is my collection of php functions/classes that helped me in my early php days. They were useful for making web apps with languages, plugins and template systems.\nI may maintain it but not so often as I don't use php that much anymore. But anyway, I leave it here so may it help another one too.\n\n# Language system\n## Intro\nA simple way to translate a full website.\n\n## Translating\nTo create a language, just create a `.json` file with the language code ([ISO 639-1](https://en.wikipedia.org/wiki/ISO_639-1)) as its name.\nIf your project is too big, you can create multiple files which name begins with `_` and the system will compile it automatically.\n\n## Using translations\nTo show a language var, you must write `[[_var_name]]`. That is, a `_` at the begining, and the name of the variable. \n\n* If the var is inside another one, you must write the whole route of variable names using a dot `.` to join them.\n* The first character to identify a variable as a language variable is a `_` but you can change it in the `global.php` file, modifying the `idioma_var` constant.\n\n# Template system\n## Intro\nEvery template is saved by default in the `/templates` folder.\nThis is not mandatory as you may save it somewhere else. But if you do so, you need to change every file and define where the folder is.\n\n## Variables\n* You can use variables that are sent from the main code, do it by adding two brackets around its name. For example, `[[var_name]]`. When the page loads, the template system will compile it and change this with the variable content.\n* It is also posible to use native PHP vars. *But pay atention*, it can produce some unexpected results if it is not defined. To do this, you use the same as before, but prepending a `$` before the name. For example, `[[$lastname]]`.\n\n## Includes\nThe template system also supports includes to load static files and separate the different site parts in several files. For example, instead of having only a `index.html` file, you may have something like:\n\n* templates/\n  * common/\n    * --- header.html\n    * --- footer.html\n    * --- navigation.html\n  * index.html\n  * contact.html\n\nThen, in the `index.html`:\n ```\n\u003c!DOCTYPE HTML\u003e\n\u003chead\u003e\n    \u003ctitle\u003eTemplate Features\u003c/title\u003e\n\u003c/head\u003e\n\u003cbody\u003e\n    \u003c!-- [include common/header.html] --\u003e\n    \u003ch1\u003eSome content\u003c/h1\u003e\n    \u003c!-- [include common/footer.html] --\u003e\n\u003c/body\u003e\n\u003c/html\u003e\n ```\nThis way, the system will load all files `\u003c!-- [include url/to/file] --\u003e`.\n\n## Conditionals\nThe template system also supports simple conditions. The syntax is like this:\n\n```\n\u003c!-- if condition then --\u003e\n...\n\u003c!-- else --\u003e\n...\n\u003c!-- end if --\u003e\n```\n\nOf course, the `\u003c!-- else --\u003e` is optional.\n\n# Plugin system\n## Intro\nThis is a simple plugin system, based on events.\nIn every file that is considered necesary, we call events in key positions, for example, when the template begins, we use `empieza_template`. And when it ends, we call `termina_template`.\nEach plugin must be designed in hooks that are called in those events. They will be run automatically.\n\n## Installer and packages\nThe plugins must be compressed in `.zip` files. The installer will decompile it and search for the `instalar.json` file.\n\n## Post-installer file: *instalar.json*\nIs a json file that should have something like this:\n```\n{\n    \"extension\": \"Extension name\",\n    \"version\": \"Version\",\n    \"autor\": \"Autor name\",\n    \"url\": \"Autor or plugin URL\",\n    \"copiar\": {\n        \"filename\": \"/copy/destination\"\n    },\n    \"sql\": [\n        \"A list will SQL Querys to be executed\",\n        \"You can use it to add plugin-specific tables\",\n        \"Or update some data\"\n    ]\n}\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faeberdinelli%2Flearning-php","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faeberdinelli%2Flearning-php","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faeberdinelli%2Flearning-php/lists"}