• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Is it normal for a coder to have all the controllers in 1 file? Main.php

Essentially just like the header says my coder currently coding with CI has around 2k of lines in main.php and didn't seperate them, here's a snipit:

function index() {
        $headerData['title'] = 'Watch Anime Online for Free - Anime Episodes, Anime Shows, and Anime Movies all for Free';
        $pageData['latestReleases'] = $this->mdlepisode->GetLatestReleases();
        $pageData['topshows'] = $this->mdlanime->GetPopular(2, 0);
        $pageData['recentcompleted'] = $this->mdlanime->GetRecentCompleted();
        $this->load->view('vw_header', $headerData);
        $this->load->view('vw_index', $pageData);
    function sidebar() {
        if ($this->vbuser->info['userid'] > 0 && !isset($_SESSION['points'])) {
            $_SESSION['points'] = $this->mdluserpoints->Get();
        if ($this->vbuser->info['userid'] > 0) {
    function login() {        
        $headerData['title'] = 'Watch Anime Online for Free - Anime Episodes, Anime Shows, and Anime Movies all for Free';
        $pageData['message'] = '';
        $pageData['loggedIn'] = false;
        // Process login
        if (isset($_POST['login'])) {
            // Set field requirements
            $this->form_validation->set_rules('username', 'username', 'trim|required|min_length[1]|max_length[100]');
            $this->form_validation->set_rules('password', 'password', 'trim|required|min_length[1]|max_length[100]');
            if ($this->form_validation->run() == true &&
                $userid = $this->vbuser->is_valid_login($_POST['username'], $_POST['password'])) {
                $pageData['loggedIn'] = true;
            else {
                // Failed login
                $pageData['message'] = 'Invalid username or password.';
Is that something needed in CI or is it bad coding practice as i do need scalability with my site? I heard that in other frameworks you can split the controller to many files, so any ideas? Thanks

There's also a poster on the forum who doesn't use [ code ] tags Tongue
Is that also normal?

Yea when it get's cutoff due to too many charactars, and somehow get's through it becomes normal Smile lol flame baitSmile

So is there a way to split the controllers or does CI force you to use only 1 controller? Thanks

Yeah you can have as many Controllers as you want, typically one for each area of functionality, so you could have one controller for users, one for messages, one for items etc. And each controller would have functions within that context, such as add, edit, delete, view etc

See the UserGuide for more info

hm, did you mean all the functions in one file?
I don´t really understand your posting.. :-)

Yea I think the coder routed everything through 1 controller which is called main.php :| As in main.php get's deleted the entire site dies. Grr I hate my coder.

[eluser]Colin Williams[/eluser]
If you hate to be organized and orderly go for it. If you want a maintenance headache, go for it. If you don't want each request to be optimized, go for it.

[eluser]Thorpe Obazee[/eluser]
Wow. One controller for the whole site? I can imagine how he will organize stuff for that.

Lol believe me if i wanted it I wouldn't be asking here if what he's doing is right or wrong. Knowing that it's doable on CI (splitting controllers) it's time to find a new coder that'll do it.

Anyone was to step up the place and finish an incomplete project or at least let me know if it's easy to split the main.php into many controllers?

Man I wish I knew more about the whole framework stuff before allowing him to get myself into this mess.

Thanks for letting me know.

If your instructions included for him to provide maintainable code you may have a point, otherwise there is nothing wrong with the job he has done for you.

I have seen worse code, But really it seems to me you are getting exactly what you paid for.

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.