Alternatives to Blade

By @dmvk · 2021-09-06 17:01

Alternatives to Blade

I have an idea to "rewrite" old legacy (but still working and actively used) CMS app with Laravel. Admin frontend is not a big deal currently, the main purpose is to have more stable and maintainable backend. The main problem form me here is rewriting a huge set of templates (DRY was not followed, yep) to blade templates. So the question is: can I use old "non-blade" templates (HTML + PHP) somehow with Laravel? Or maybe some kind of "migrating" tool that can reduce the amount of routine work exists?

  • By @dmvk · 2021-09-12 14:56

    I'm ashamed to admit: I didn't know that Laravel actually CAN render plain php templates without any special syntax...

  • By @atymic · 2021-09-10 07:48

    I guess it really depends on the format of your old views. Is there some sections where the content is consistent? I've previously taken the approach of breaking files into sections, and splitting the bits out into files automatically. For example, parse an old template, remove the menu and replace it with a @include or whatever, replace all instances of <?= $var ?> with {{ $var }}, etc. Chances are you're still going to end up having to do some manual work.

    Once you're ported, write a script to query the old and new codebases and diff the responses to see what's different.

  • By @Focus3D · 2021-09-07 08:52

    Hi Dmitriy, I will suggest using laravel stubs by creating a command to create custom views or you could fork and customize it or get inspiration for the command generator. In fine, you should organize your old app using search and replace and regex to remove. Unfortunately there is no magic wand to interpret the code when it is not structured (so no marker for the script to copy or insert code). No pain No gain 😊 Good luck