I'm currently working on a PHP/MySQL app that I've been developing on HostGator (moving to KnownHost soon). My frontend consists of basic HTML, CSS, and JavaScript, and uses PHP to render templates along with a bunch of JS files for interactivity. I'm the sole developer, and as the project evolves, maintaining the code has become increasingly cumbersome. I'm dealing with lots of repeated code for rendering elements like large tables and modals, and each time I want to implement a UI change, I find myself creating new PHP files just to include the necessary HTML and JavaScript. It feels inefficient, and I know there's a better approach out there.
As such, I'm thinking about migrating to a modern framework. My options include React, Angular, Vue, and Livewire (which seems PHP-friendly but maybe not as scalable). My main goals are to:
1. Write modular code that's easier to modify.
2. Keep hosting straightforward without complicated deployments.
3. Transition gradually instead of doing a complete rewrite.
4. Minimize the need for fiddling with HTML/CSS to achieve the right design.
Has anyone else made a similar switch? Which framework do you think would offer the smoothest transition considering my PHP backend? Any advice on structuring a migration plan would be greatly appreciated!
5 Answers
Honestly, the problem seems to be your current code structure rather than the absence of a modern framework. Focus on organizing your code effectively, and it might resolve many of your issues without a major migration.
Have you thought about using a templating engine like Twig? It’s a great middle ground that could simplify your current setup without needing a full overhaul to a headless PHP back end with a React SPA in front. It allows for better templating and rerendering of data, making your life easier without starting from scratch. Definitely worth a look!
You're definitely not an idiot! Many web apps start with server-side rendering. Given your PHP background, considering Laravel with Livewire might be a smooth path. It's modern but keeps you within the PHP framework you’re already comfortable with. Also, check out the HACK language if you want something that resembles React in PHP. Another option is using web components for better modularity; Lit library can help with that while keeping your frontend manageable.
Here’s a few ideas:
1) Try simplifying your JavaScript by organizing it into importable files instead of mixing it in with your PHP code. It’ll really cut down on duplication.
2) You can transition your PHP to use a built-in templating system, breaking files into digestible pieces you can import.
3) Don’t worry about doing it all at once; you can handle migration piece by piece and keep everything functional as you go.
Since you’re already familiar with PHP, you can't go wrong with Laravel combined with Inertia and Vue. It's a nice blend that allows for gradual upgrades while keeping your existing setup intact. It's worth considering!

That sounds promising! I'll definitely check out Twig. Thanks for the suggestion!