When django nextjs and Laravel failed me… - 02/02/2023
So
medium-to-markdown@0.0.3 convert node index.js https://medium.com/@birnadin/when-django-nextjs-and-laravel-failed-me-f33f1021091f
When django, nextjs and Laravel failed me…
[
](https://medium.com/@birnadin?source=post_page-----f33f1021091f--------------------------------)
·
5 min read·Feb 2, 2023
—
Listen
Share
it’s write-from-scratch magic time.
The Problem
A few months ago, I was tasked to update a few blogs on my school’s website. The previous one was in WordPress, and it was taunting to figure out how-to stuff within WordPress due to the fact it was full of add-ons or plugins, whatever 😒. Since it wasn’t doc’d had to dig into and those efforts did nothing.
The Trouble Begins
So, we (Patrician Publications Club) decided to re-spin up and that would make our life easy. SO I thought. I decided to go with `django` as I was well familiar with almost 2 years of experience as of 2021-mids, but the problem was ME. SUPRISE 😲. The THING about me is I wanna live on the edge. So, django it is. BUT, there wouldn’t be anyone after me to maintain django as well, like I couldn’t manage the WordPress site. I asked some juniors who had an interest in these kinda misc. acts, but to my surprise, none of them seems to apprehend the request-flow of django and the architecture of CLASS_BASED views and in-depth raw-sql ops. So, almost 2 months of development were wasted because I didn’t think it through during the feasibility analysis.
Change of Plans
So, I decided to go with something my juniors knew. JavaScript frameworks 🤢. I don’t like JavaScript running in the backend as much as I like python. Both are interpreted but, I don’t know why, but I hate NodeJs and love python 🤷♂️. But due to constraints, I went ahead and decided I would use nextjs(12 at that time). Now the problem was again ME. I am a backend engineer with somewhat knowledge of CSS. I couldn’t get to know all those responsive design stuff. Thus, I used templates from Envato for my school. I and my colleague landed on a template. But, the template we chose, spat right at it when its FAQ in `README` said…
How to populate from php?
Note that this template was not built for dynamic content, the template only supports static html.
😡 Should have said that during purchase! We tried using all kinds of hooks from react and next, but nothing inter-operated with js from the templates. React wasn’t finished with the DOM when jquery animation plugins kicked in. Blood all over the chrome dev console 🔪🩸. No matter, how much I dig deep I can, couldn’t aligned react event with jquery `dom-ready` events. I gave up 🥺. The author was right, **Not for dynamic content**.
New territory, New Journey
Another template, then? Way over budget! Another couple of months went by. Even after a quad year, I produced nothing! It’s just void. Being a Patrician…
Fide et Labore.
I said, screw it, let’s do this with `php`, the forbidden legacy. But, I didn’t know PHP! 🤦♂️. Since I saw no other way, I learned it from freecodecamp. With that, I started developing with php, even though author says, no dynamic content. Then it hit me, there is no templating in plain php(from my 3 hours of knowledge of php ecosystem). I just realized how much better django was w.r.t. plain php, which is intended to be used for web dev. Since react took care of it when I decided `js`, but now I know what to do.
Search for a PHP template engine
I was introduced to `Laravel`, PHP artisans’ framework. I got what I needed, THE `blade` templating language. It was perfect.
me to blade templating 😍
Laravel took care of auth, routing, view-model mapping (even though a lot of boilerplates for a small web project like mine) but I love it. I felt much breeze with Laravel only about a day experience or so which took me months in my early days of django. Within 3 weeks I submitted, and our Vice Rector said, Ok. So, now we deploy.
🤦♂️😢🥺 Deploy it
Deploy! I forgot that part of the project entirely. Deploying django was easy, just push to CD, and spin docker container or on the bare metal. You might think about how else Laravel be deployed from this. You are right, Laravel follows the same, actually much easier. But, in a traditional way or should I say, the FRAMEWORK-way of doing. Our school website was hosted on Shared Hosting.
me tryna deploy
The thing about shared hosting is that you get now SSH, fs or such. just (s)ftp account and creds for mysql conn, which can only be used within the host’s LAN/WAN network. Shoulda think thoroughly during feasibility analysis. 🤦♂️🤦♂️🤦♂️
Slipping through the system and going against the morals
Though some forums claimed you can’t host Laravel in shared hosting, some YouTube vids shed some light. Upload the entire vendor folder and change .htdocs along with some changes to frameworks internal files which are responsible for plugin discovery and a few other stuff I really didn’t understand but I just copy-cat the tuts. Now, after a few days, Laravel was up and running 😜. The pain was watching ftp sync the dependencies one by one, almost 29k files were transferred 😰.
But the site was up and beta-testers (a few onboard staff and alumni) could browse and, yeah. 💖
So, I thought, 😂
Let’s do this one more time, shall we?
Every single feedback was,
Waiting time is long.
So, I went ahead and. Yeah, I could feel it, not 100ms, 1s delay, but 6s to 21s(yes, I thought my monthly quota was finished). So, debug and fine-tune, eh? So, I put the time to log on each method, class (de)constructors and all, and apache logs yelled at me this
1s to 4s waiting for the files to be traversed and read for the interpreter to interpret.
Maybe this is why Laravel had a build step at the end. 🤷♂️ I didn’t do that cause, that option is not for shared hosting. File read in this particular hosting was very slow 🐌
So, with a product that is not usable, I hibernated the project as it was my A levels approaching.
But today, it’s the new dawn!
But today(Jan 28, 2023; almost 17 months after the assignment) with my main subjects’ exams done, I decided to write my web dev framework. that can do what I need it to. In the next post, I will tell you what my strategy is. Thanks to `Qwik` and `SvelteKit` for inspiring new ideas.
Epilogue
If you are intrigued and interested, make sure you follow me on Medium or Twitter for follow up.
So, I guess that’s it. New year, New Dawn, new side project to abandon mid-ways. Till next time, it’s me the BE signing off.
Cover Photo by Monstera.