Code.Movie 0.0.32 adds support for PHP! Code.Movie is a JavaScript library that animates source code for the web - imagine a combination of git diffs, virtual DOM diffing, syntax highlighting, code annotations and CSS animations.
<?php $animals = [];
<?php $animals = ['dog', 'cat', 'cow', 'duck', 'goose'];
<?php $animals = ['dog', 'cat', 'cow', 'duck', 'goose']; $animal = array_find();
<?php $animals = ['dog', 'cat', 'cow', 'duck', 'goose']; $animal = array_find( $animals, );
<?php $animals = ['dog', 'cat', 'cow', 'duck', 'goose']; $animal = array_find( $animals, static fn ($value) => str_starts_with($value, 'c'), );
<?php $animals = ['dog', 'cat', 'cow', 'duck', 'goose']; $animal = array_find( $animals, static fn (string $value): bool => str_starts_with($value, 'c'), );
<?php $animals = ['dog', 'cat', 'cow', 'duck', 'goose']; $animal = array_find( $animals, static fn (string $value): bool => str_starts_with($value, 'c'), ); var_dump($animal);
<?php $animals = ['dog', 'cat', 'cow', 'duck', 'goose']; $animal = array_find( $animals, static fn (string $value): bool => str_starts_with($value, 'c'), ); var_dump($animal); // string(3) "cat"
As the above animation shows, PHP is now supported by Code.Movie. Core library, playground and documentation have been updated accordingly. Import the language module from the core library and go from there as usual:
import { animateHTML } from "@codemovie/code-movie";
import php from "@codemovie/code-movie/languages/php";
let html = animateHTML([{ code: '<?php echo "Hello World!"; ?>' }], {
tabSize: 4,
language: php(),
});
1234567import { animateHTML } from "@codemovie/code-movie";
import php from "@codemovie/code-movie/languages/php";
let html = animateHTML([{ code: '<?php echo "Hello World!"; ?>' }], {
tabSize: 4,
language: php(),
});
The usual caveats apply: I don't speak or use PHP myself, so syntax and animation heuristics may at this point not be as good as with other languages. Bug reports are welcome!
{ fromLine: 1, toLine: 5}
in a document with only 3 lines) instead of the previous undefined and apparently random behavior