https://github.com/pp3345/moody
PHP Code Preprocessor
https://github.com/pp3345/moody
Last synced: 11 months ago
JSON representation
PHP Code Preprocessor
- Host: GitHub
- URL: https://github.com/pp3345/moody
- Owner: pp3345
- Created: 2012-08-12T19:14:58.000Z (almost 14 years ago)
- Default Branch: master
- Last Pushed: 2023-10-05T22:54:33.000Z (over 2 years ago)
- Last Synced: 2025-04-06T13:45:43.961Z (about 1 year ago)
- Language: PHP
- Size: 422 KB
- Stars: 4
- Watchers: 1
- Forks: 2
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Moody PHP Preprocessor
## What is Moody?
Moody is a small scripting language specially designed for preprocessing PHP sources.
Moody itself also contains some modules used for optimizing PHP code, without the need to write any new code.
It will just give you an optimized version of your PHP code. At the moment there are not too many
automatic optimization modules, but they will be more in the future. :-)
## How to write code in Moody?
Moody code is written in PHP comments. Look at these examples of Moody code:
```php
8
echo 'Hello ';
#.endif
echo 'World!;'
?>
```
When preprocessed using Moody, the following code would be generated:
```php
```
This example is somewhat useless, but let's say the variable would have a dynamic
value (for example obtained through the programs' configuration) and the code in the if block would make
a little bit more sense, you could remove unnecessary code from the compiled program. This will save you a
check for a specific configuration value on each iteration and - more important in such examples - the RAM used up
for simply having code loaded that will never be run anyway.
You can call any PHP function or static method (objects currently not supported) from Moody:
```php
```
Moody will parse PHP namespaces and PHP constants and even substitute read occurences in the generated code:
```php
```
This would generate the following code:
```php
```
This also gives you a small performance improvement since the constant does not have to be resolved at script
runtime anymore.
## Contact
If you got questions about Moody or just want to learn more, feel free to contact me at [dev@pp3345.net](mailto:dev@pp3345.net). :-)