Search code examples
phpparsingsymfony1yaml

Using php code in symfony YAML as string value


I want to create some YAML key with value - the code in php. But this code shouldn't be executed - I want to use it as the value itself. How can I do this?

Example:

somekey: <?php echo 1; ?>

This line shouldn't be recognized as somekey: 1 after parsing - I want to receive value for somekey key as <?php echo 1; ?>.

Update:

I want to use this to store some code in database (with fixtures.yml) and then load it and use as php-based template.


Solution

  • I invented my own solution. It looks badly but works:

    somekey: "<?php echo '<?php echo 1; ?>'; ?>"