{"id":20429045,"url":"https://github.com/pp3345/moody","last_synced_at":"2025-07-11T21:34:11.692Z","repository":{"id":4263903,"uuid":"5391038","full_name":"pp3345/Moody","owner":"pp3345","description":"PHP Code Preprocessor","archived":false,"fork":false,"pushed_at":"2023-10-05T22:54:33.000Z","size":432,"stargazers_count":4,"open_issues_count":6,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-06T13:45:43.961Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/pp3345.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":"2012-08-12T19:14:58.000Z","updated_at":"2024-07-05T06:02:17.000Z","dependencies_parsed_at":"2025-01-15T16:53:04.287Z","dependency_job_id":"515f856d-1530-49a1-8af3-b0d786789acb","html_url":"https://github.com/pp3345/Moody","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/pp3345/Moody","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pp3345%2FMoody","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pp3345%2FMoody/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pp3345%2FMoody/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pp3345%2FMoody/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pp3345","download_url":"https://codeload.github.com/pp3345/Moody/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pp3345%2FMoody/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264902805,"owners_count":23681122,"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-15T07:32:44.393Z","updated_at":"2025-07-11T21:34:11.629Z","avatar_url":"https://github.com/pp3345.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Moody PHP Preprocessor\n\n## What is Moody?\n\nMoody is a small scripting language specially designed for preprocessing PHP sources. \nMoody itself also contains some modules used for optimizing PHP code, without the need to write any new code. \nIt will just give you an optimized version of your PHP code. At the moment there are not too many \nautomatic optimization modules, but they will be more in the future. :-)\n\n## How to write code in Moody?\n\nMoody code is written in PHP comments. Look at these examples of Moody code:\n\n```php\n    \u003c?php\n     #.myVar = 7\n     #.if myVar \u003e 8\n      echo 'Hello ';\n     #.endif\n     echo 'World!;'\n    ?\u003e\n```\n\nWhen preprocessed using Moody, the following code would be generated:\n\n```php\n     \u003c?php\n       echo 'World!';\n     ?\u003e\n```\n\nThis example is somewhat useless, but let's say the variable would have a dynamic \nvalue (for example obtained through the programs' configuration) and the code in the if block would make \na little bit more sense, you could remove unnecessary code from the compiled program. This will save you a \ncheck for a specific configuration value on each iteration and - more important in such examples - the RAM used up \nfor simply having code loaded that will never be run anyway.\n\nYou can call any PHP function or static method (objects currently not supported) from Moody:\n\n```php\n     \u003c?php\n      #.randomValue = #.rand 0, 1\n\n      #.if randomValue == 1\n        echo 'Do it!';\n      #.else\n        echo 'Better not do it!';\n      #.endif\n     ?\u003e\n```\n\nMoody will parse PHP namespaces and PHP constants and even substitute read occurences in the generated code:\n\n```php\n     \u003c?php\n       namespace MyNamespace {\n         const namespacedConst = \"abc\";\n\n         $someVar = namespacedConst;\n       }\n \n       namespace {\n         const myConst = 8;\n\n         #.moodyConst = 123\n\n         $x = myConst;\n         $y = MyNamespace\\namespacedConst;\n         $z = moodyConst;\n       }\n     ?\u003e\n```\n\nThis would generate the following code:\n\n```php\n     \u003c?php\n       namespace MyNamespace {\n         const namespacedConst = \"abc\";\n\n         $someVar = \"abc\";\n       }\n  \n       namespace {\n         const myConst = 8;\n\n         $x = 8;\n         $y = \"abc\";\n         $z = 123;\n       }\n     ?\u003e\n```\n\nThis also gives you a small performance improvement since the constant does not have to be resolved at script \nruntime anymore.\n\n## Contact\n\nIf you got questions about Moody or just want to learn more, feel free to contact me at [dev@pp3345.net](mailto:dev@pp3345.net). :-)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpp3345%2Fmoody","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpp3345%2Fmoody","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpp3345%2Fmoody/lists"}