SOME BACKGROUND INFO: So I'm sorta a "expert beginner" in PHP which is kind of bad and I came to this conclusion about a week ago. I did not go to school for web dev, in fact my background comes from Indie Game development since I own my own team. I picked up web dev when my previous employer asked if I knew anything about web programming vs making computer software since they were planning on migrating stuff to the Web and their servers were already dependent on MYSQL. I left the employer after creating a very crappy CRM they were surprisingly happy with but I went off to try and start my career. I landed an entry level job with my current employer which the story begins.
EDIT: "Expert beginner" means I suck ass and maxed out the basic fundamentals but not enough to get to a competent stage, ofc I'm doing my best to get out of this cycle being someone who didn't go to school for this and am a High School dropout.
**Presently and my dilemma :**
Every job out there as a fullstack regards to some sort of framework tied to it aka Laravel, I've heard of MVC structures in the past but never really dived deeper into the rabbit hole. I'm currently learning OOP which is fairly simple to get down not to hard if you have any sort of coding background but.... MVC seems to pass me by. In fact it seems my employer has been teaching me shit in the early myspace era without a framework hence.... when I figured out I'm in pretty deep shit.
**The way I was taught By my employer:** the File structure is fairly simple and mostly include oriented.
1.lets say we have 3 pages index.php > about.php > contact.php
2. The index.php has the original "shell" contained only with HTML and no php
3. I split up the Header > Body > Footer into 3 separate php files in a seperate folder called "includes"
4. the file structure looks like
index.php:
<?php
include('includes/header.php');
include('includes/body.php'); ///We change this depending on which file so if its about.php we use "aboutbody.php"
include('includes/footer.php');
?>
this is just a basic example of course sometimes we split up the code based by "section" and include it in the main file but lately i've been just splitting it up into sections and including it in the body.php this allows us to just reuse sections in different parts of the sites etc.
we slap the mysql into a config.php file and then include it on the top of the "header.php" file in case we need to do any database querying.
Sometimes I echo out html elements if we're lets say creating a rankings page we do something like
getRankings.php
$html_str = '';
while ($row = mysqli_fetch_assoc($result)){
$html_str = '<div> <h1>This Company is Ranked #'.$row['rank'].'</h1></div>'
}
and in the main html part of it it'd be like
<div class="container"><?php echo $html_str?></div>
This is echoed out only on "rankings.php"
Now I'm really unsure if this is a good practice or not but my understanding after reading about MVC is that this structure is somewhat similar to MVC albeit without OOP can I say that splitting up the pages into includes is considered the "model"? Would the main pages directly be the "view"? And would be the "config.php" and any function files I include with it be I guess the controller?
I've been reading up docs but its pretty hard to grasp Laravel in general where exactly is Laravel used here? It's pretty bulky and pretty overkill for making web pages for a landing page etc. People tell me it's serverside, so would I lets say use basic php for the landing pages and then use Laravel on the backend for a CRM system aka they are split up into 2 different directories.
In my case we usually create CRM in a separate folder so they'd have to access it like "mypage.com/my-crm".
To my understanding OOP is only really used to prevent the procedural code from firing i looked into one of the previous developers who had worked with my current employer and he built a crm which had a class called "app" which pretty much handled all the operations based on the current page. But it seemed like ALL of the app's functions for all the pages were there.
class app {
//Functions relating to pulling Leads
//Functions relating to pulling sales
//functions relating to pulling users
//functions relating to pulling blah
}
is this the "general idea" of how you would build a php backend app?
Really would like to be enlightened here and please tell me how screwed I am. Where,when and what laravel is specifically used for.
I get that its for the libraries and and all that stuff and probably will learn it eventually... but I know full well I wont improve working here with my boss.
EDIT: FOR ANYONE IN MY POSITION / STUCK and YOU FEEL LIKE YOU DON'T UNDERSTAND MVC or EVEN IF YOU'RE JUST A BEGINNER/LOOKING TO LEARN LARAVEL. I HIGHLY HIGHLY HIGHLY RECCOMEND THIS DUDE. GIVE HIM A CHANCE AND SOME LOVE.
Quick Programming - YouTube
Not only has he taught me the fundamentals of OOP and MVC , he's super responsive and willing to answer your questions on his Facebook page. Just today I asked If he can cover Laravel on his channel since he already covered MVC, He's making a new video as we speak. If you don't know the Fundamentals of MVC or OOP I highly recommend looking at his MVC Template project in which you're able to just use that to build your own or professional projects. When you feel comfortable and want to upgrade, you'll have an understanding of MVC and just need to learn the folder structures for Laravel. He provides PRACTICAL examples of where and when and how you would use something it may not be true for everyone but at least It's close to what I do for my boss on the daily. Godspeed and good luck.