Reputation: 10095
I've just started looking at PHP Frameworks after spending loads of wasted time doing everything from scratch. I thought I would give Codeigniter a go after a friend recommended it to me.
I worked through the first tutorial and there were no issues but I'm getting stuck with the second one.
At first my code was identical to the tutorial:
<?php
class Blog extends CI_Controller{
function Blog()
{
parent::CI_Controller();
$this->load->scaffolding('entries');
}
public function index(){
$data['title'] = "My Blog Title";
$data['heading'] = "An intresting title";
$data['todo'] = array('create media player','design site','finish project');
$this->load->view('blog_view',$data);
}
}
?>
But I got an internal server error. After looking at the user guide it shows a different way for using the constructor.
I changed the code to the document spec.
<?php
class Blog extends CI_Controller{
public function __construct() {
parent::__construct();
$this->load->scaffolding('entries');
}
public function index(){
$data['title'] = "My Blog Title";
$data['heading'] = "An intresting title";
$data['todo'] = array('create media player','design site','finish project');
$this->load->view('blog_view',$data);
}
}
?>
But I still get an internal error. I don't know if my code is wrong or I misconfigured something else. Some advice would be good, thanks.
Edit: To clarify - I only get an internal error when I add the constructor to the class.
Upvotes: 0
Views: 345
Reputation: 75327
This will most likely because you're trying to load scaffolding
in the latest version of CodeIgniter.
Scaffolding has been depreciated since version 1.6. It was removed in 2.0, and the latest version is now 2.0.2
In terms of which of your provided snippets to use, the latter form of declaring a constructor (__construct
) is preferred over using the Class name (Blog
). This method is also consistent with the Core Classes of CodeIgniter since 2.0.
As an aside, I've got no idea why CodeIgniter are including such out-of-date samples in their tutorials. EllisLab's seem to have lost total interest in the CI project recently, which is a shame :(
Upvotes: 5
Reputation: 6346
Internal error means there's mis-server configuration.
Usually .htaccess file or apache settings. Try this:
This also removes index.php, which you should look into.
Upvotes: 0