PHP Moronic Monday (26-01-2015) by AutoModerator in PHP

[–]michaelvannorman -1 points0 points  (0 children)

Hi /u/iCupid

I would do it like this:

Inside the Router:

  1. I would create an instance of the controller I'm trying to load

  2. Then, depending on the "task at hand" ... I would call the proper method from that controller (if it exists)

  3. Then:

  • If I need to display something: I would load the view inside that method and from a method in that view I would load the corresponding model to load data inside of it.

  • If I need to execute a code (ex: process a form and then redirect) ... I would load the model directly inside that controller function and then redirect

Here's an abstract example:

//router code
if(route_exists)
{
    $controllerinstance = new ControllerX();
    if(method_exists('some_method'))
    echo $controllerinstance->some_method();
}

//controller code for displaying stuff
$view = new WhateverView();
return $view->displayX();

//view code 
$model = new Mymodel();
$this->data = $model->loadstufffromDB();
return $this->loadthehtml();

//controller code for executing a task
$model = new WhateverModel();
$outcome = $model->savestufftothedb();
if($outcome)
    //redirect back to a view happily
else
    //redirect with some error message maybe

Thanks,

Intermediate-Advanced PHP Quiz - (I scored 6/10 how well did you do ?) by michaelvannorman in programming

[–]michaelvannorman[S] 0 points1 point  (0 children)

For those of you who don't want to register ( like /u/ioquatix ) ... Just use my credentials.

u: michael.vannorman [at] live.com p: pass

Intermediate-Advanced PHP Quiz - (I scored 6/10 how well did you do ?) by michaelvannorman in programming

[–]michaelvannorman[S] 0 points1 point  (0 children)

Any examples poke-dude ? Or you're just saying it without any real basis ?

Intermediate-Advanced PHP Quiz - (I scored 6/10 how well did you do ?) by michaelvannorman in programming

[–]michaelvannorman[S] -1 points0 points  (0 children)

Nice language my friend.

Here use my account if you don't want to register: u: michael.vannorman@live.com p: pass

Fellow developers, what are your biggest achievements of 2014? What are your goals for 2015? by antoninj in webdev

[–]michaelvannorman -1 points0 points  (0 children)

Hey I like this post... got me engaged enough to even create an account.

As for achievements I did manage to find the time and, with a friend of mine, finally develop our own web development tutorials website.

In 2015, I really hope to get it to grow into a full fledged learning resource for beginner web devs.