I have an error when try upgrade codeigniter 1.7 to 2.X in the hook area
$this->CI->load->library('session');
$this->CI->load->model('administrator');
Those lines no working in my hook
Here my hook contructor
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Security
{
private $CI;
public function __construct ()
{
$this->CI =& get_instance();
$this->CI->load->library('session');
}
It's shows error in the library and in the model $this->CI->load->model('name_model');
I was follow the steps in codeigniter but the hooks no working, I'm check the config and everything is supose ok.
The hook not load the model and libraries. And I do not why.
In order to upgrade CI from 1.7 to 2.X, you have to follow this complete tutorial.
http://ellislab.com/codeigniter/user-guide/installation/upgrade_200.html
Follow it exact step by, And for your reference in CI 2.X you have to Update your Class extension, means All core classes are now prefixed with CI_. Update Models and Controllers to extend CI_Model and CI_Controller, respectively.
$this->CI->load->library('session');
$this->CI->load->model('administrator');
These lines will not work in CI 2.X
Related
It is working correctly with MX_Controller.It is throwing error as 'Fatal error: Class 'CI_Template' not found' when using REST_Controller.Any help will be appreciated.
I'm not entirely familiar with the inner workings of Codeigniter's third party add-on HMVC. However, the code base that I inherited is using it.
I ran in to the same issue when installing restserver, https://github.com/chriskacerguis/codeigniter-restserver which is what I assume you were also doing.
REST_Controller.php has this
abstract class REST_Controller extends \CI_Controller {
While I have never been able to get CI_Controller to work with this codebase, I now believe it is because of this HMVC. For those not familiar, HMVC is Hierarchical Model View Controller.
Module Controllers can be used as normal Controllers or HMVC
Controllers and they can be used as widgets to help you build view
partials.
https://bitbucket.org/wiredesignz/codeigniter-modular-extensions-hmvc
I did get REST_Controller.php working by changing the line to
abstract class REST_Controller extends \MX_Controller { // \CI_Controller {
My model is:
/application/models/tester.php
The code inside is:
class Tester extends CI_Model
{
function __construct()
{
parent::__construct();
$this->load->database();
}
}
And here's the usage:
class Hauth extends CI_Controller
{
public function index()
{
$this->load->view('hauth/home');
}
public function login($provider)
{
// Load models
$this->load->model('Tester');
// Load helpers
$this->load->helper('url');
log_message('debug', "controllers.HAuth.login($provider) called");
It works perfectly on my local WAMP server but I get this error on the LAMP production envrionment:
An Error Was Encountered
Unable to locate the model you have specified: Tester
I've looked at a dozen StackOverflow questions that appear to be similar but I've tried all of the solutions posted. As far as I can tell, I've followed the CI manual to the letter. I figured that perhaps file names were an issue WAMP vs LAMP so I confirmed the case of the file names via FTP. Thought it might be a naming conflict, so I renamed them "tester". Again, works perfect on local, but not on live.
I found the problem. Turns out I accidentally used a zip of Codeigniter 3.0-dev. When I moved my application files over to the latest stable version, everything instantly worked.
I'm trying to integrate Google Calendar in my php application (I use CodeIgniter for this).
I have a problem with my controller calendar.php.
<?php
session_start();
Class Calendar extends Controller {
function Calendar(){
echo 'start';
parent::Controller();
echo 'okkkkkkkk';
require_once '/home/me/framework/ZendGdata/library/Zend/Loader.php';
Zend_Loader::loadClass('Zend_Gdata');
Zend_Loader::loadClass('Zend_Gdata_AuthSub');
Zend_Loader::loadClass('Zend_Gdata_ClientLogin');
Zend_Loader::loadClass('Zend_Gdata_Calendar');
}
but there is a problem with parent::Controller() because 'okkkkkk' is not printed.
Could anyone help me please?
Change
parent::Controller();
to
parent::__construct();
parent::Controller() doesn't work in CI because as of CI 2.1.2, the constructors are declared using PHP's __construct() method.
As a sidenote, it seems you are using an older version of CI. CI 2.o onwards, the base controller class is called CI_Controller as opposed to just Controller. You should look into updating your project by replacing the system folder.
You can find the full working code in this following link https://github.com/omerkamcili/ci_google_calendar_api.
After down loading the code create your service account, OAuth client Id's in the following link http://console.developers.google.com.
Then replace the client_id,client_secret,redirect_uri's in your project file in the following path -> /project_folder/application/config/client_secret_846685841138-t0a5b9d2i655e7km54md8j440jcg5rr5.apps.googleusercontent.com.json file
Finally download and replace the google-api-php-client in the following file path /project_folder/application/third_party/google-api-php-client
I am facing a Fatal error:
Class 'Controller' not found in D:\wamp\www\CodeIgniter\application\controllers\blog.php on line 3
I am typing write and i watched so many tutorials they are also typing beginning code like this i tried a lot to find out but got no reason
Are you using CI 2.O? Did you by any chance write the following in your controller:
class Blog extends Controller { ... }
If you're using CI 2.0, you should use the following:
class Blog extends CI_Controller { ... }
You might have been watching outdated tutorials for CI 1.7.
Reference: http://codeigniter.com/user_guide/general/controllers.html
Make sure to follow the userguide along with whatever tutorials you're following; there's some changes in 2.0 which you should be aware of. You can still follow these tutorials though, just keep your eyes open and compare with the userguide.
What version are you using? if you're using the latest (2.0.2), make sure you use CI_Controller when extending your controller.
Seeing you named the file blog.php, your controller should be looking like this
Class Blog extends CI_Controller {
function index()
{
// your code...
}
}
i just want to run $CI=&get_instance in Exception library of codeigniter. but its not running there. while the other Classes in Library folder are able to create such instance, but the Exception is not. the reason i want to do this is , i want to use this instance to load a view page in show_404(){} method.
thanks in advance
Are you thinking about extending CI's Exceptions library? if so, you may want to do
<?php
class MY_Exceptions extends CI_Exceptions {
// your code here
}
then you don't need to do $CI &= get_instance();