PHP - Codeigniter professional structure -


i graduating in next month. applying entry level php developer jobs. many companies asking send sample code.

i sending sample controller, view , model files , screenshots of outputs, not getting through.

please me. doing wrong? supposed send them? there professional way of writing/structuring code?

my sample code files are:

controller

<?php  class newsrelease extends controller {     function newsrelease()     {         parent::controller();         $this->load->helper('url');         // $this->load->helper('form');         $this->load->model('news_model');         $this->load->library('session');     }      /*     loads home page called 'home_view'. before loading this,     checks wheter admin logged in or not , clears admin     session. because, when admin logged out, shown page.     */      function index()     {         $checksession=$this->session->userdata('name');         if(isset($checksession))         {             $this->session->unset_userdata('name');             $this->session->unset_userdata('password');         }         $this->load->view('home_view');     }      /*     on loading home page, display feature news, following     function needed.     */      function datanews()     {         //$data['hi']="hello world";         $query=$this->news_model->getactivenews();         foreach($query->result_array() $row1)         {             echo"<p><h4><b><a href='#' id='".$row1['id']."'>".$row1['title']."</a>             </h4></b>".substr($row1['body'],0,100)."<b>...<a href='#'              id='".$row1['id']."'> read more></b></a></p></br>";         }         }      /*     archive news can shown function.        */      function archivenews()     {         $year=trim($this->input->post('year'));         $query=$this->news_model->getarchivenews($year);         foreach($query->result_array() $row1)         {             echo"<p><h4><b><a href='#' id='".$row1['id']."'>".$row1['title']."</a></h4>             </b>".substr($row1['body'],0,100)."<b>...<a href='#' id='".$row1['id']."'>              read more></b></a></p></br>";         }     }      /*     on clicking admin link on home page, navigated     admin login page.     */      function adminlogin()     {         $this->load->view('adminlogin_view');     }      /*     admin login authentication can handled thie function.     , session stores id , password.      */      function validate()     {         $name=trim($this->input->post('name'));         $password=trim($this->input->post('pwd'));          $sess_data=array("name" => $name,             "password" => $password);         $this->session->set_userdata($sess_data);          if($name=="raj"&&$password=="raj")         {             echo "1";         }         else             echo "0";     }      /*     after successful authentication, admin shown home page     can add, modify , delete news.     */      function adminhome()     {         if($this->session->userdata('name') && $this->session->userdata('password'))             $this->load->view('adminhome_view');     }      /* , more functions go here. */  ?> 

view

<?php $this->load->view('header'); ?> <!-- scripthome.js has javascript , jquery code related functions above mentioned process-->  <script type="text/javascript" src="<?php echo base_url();?>js/scripthome.js"></script> <div id="content">      <h3 class="featurenews"><a href="#" id="feature"> feature news </a></h3><h3 class="admin"><?php echo anchor('newsrelease/adminlogin','admin')?></h3>       <div id="newsdetails">         <!-- feature news details-->     </div>     <!--     archive page should display list of active news items in descending order (newest oldest     based on release date). similar home page, archived news item features title, portion of     story , allow users ability either click title or "read more" link view entire     story     -->      <div id="newsarchivedetails">         <!-- archive news-->     </div>      <div id="newsarchive">         <!-- archive news-->     </div>     <div id="newshome">         <!-- feature news-->      </div>     <div id="archivediv">         <h3 class="archive">news archive by</h3><h3><a href="#" id="2010"> 2010 </a> | <a href="#" id="2009"> 2009 </a> | <a href="#" id="2008"> 2008 </a></h3> <a href="#" id="2007">2007</a>     </div>     <!-- content close -->  </div>  <!-- wrapper close --> <?php $this->load->view('footer');?> 

model

<?php  class news_model extends model {     function news_model()     {         parent::model();         }      /*     gets featured news table news.     */      function getactivenews()     {         $this->db->where('status','1');         $this->db->where('type','1');         $this->db->order_by('id','desc');         return $this->db->get('news');      }      /*     gets news type '0'(archived)     */      function getarchivenews($year)     {         $this->db->where('year(date)',$year);         $this->db->where('status','1');         $this->db->where('type','0');         $this->db->order_by('id','desc');         return $this->db->get('news');     }  }  ?> 

  1. you start removing html tags controller class (mvc)
  2. create propper documentation (@return, @param, etc.)
  3. most companies want see code + working version of code on live server
  4. if it's not codeigniter specific job, show non-codeigniter code
  5. show em can read/write uml diagrams
  6. add variety (xml, soap, oop, different dbtypes, file upload, sessions, security, etc.)
  7. point out build code atleast test driven development or behaviour driven development

and ofc.. luck!!


Comments

Popular posts from this blog

android - Spacing between the stars of a rating bar? -

aspxgridview - Devexpress grid - header filter does not work if column is initially hidden -

c# - How to execute a particular part of code asynchronously in a class -