Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6760395
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T14:03:34+00:00 2026-05-26T14:03:34+00:00

I have a CodeIgniter project, and I want to invoke one of my controller

  • 0

I have a CodeIgniter project, and I want to invoke one of my controller methods via CLI, but normal properties & methods that are attached to the CI superobject seem to be missing?

For example, running the following script which runs perfectly fine during a normal http request produces an error:

class Worker extends MY_Controller {

    public function __construct() {
        if(php_sapi_name() !== 'cli') {
            show_404();
        }
    }

    public function test(){

        $this->load->library('some_library');

    }
}

This is the error that’s returned via the CLI

  <div style="border:1px solid #990000;padding-left:20px;margin:0 0 10px 0;">

<h4>A PHP Error was encountered</h4>

<p>Severity: Notice</p>
<p>Message:  Trying to get property of non-object</p>
<p>Filename: controllers/worker.php</p>
<p>Line Number: 21</p>

</div>PHP Fatal error:  Call to a member function library() on a non-object in /Users/casey/Documents/workspaces/vibecompass_live/application/controllers/worker.php on line 21

Fatal error: Call to a member function library() on a non-object in /Users/casey/Documents/workspaces/vibecompass_live/application/controllers/worker.php on line 21

I’m calling the script as such:
$ php index.php worker test

EDIT

Additionally, this script:

class Worker extends MY_Controller {

    public function __construct() {
        if(php_sapi_name() !== 'cli') {
            show_404();
        }
    }

    public function test(){

        $CI =& get_instance();
        var_dump($CI); die();

        $this->load->library('some_library');

    }
}

Returns: NULL

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T14:03:35+00:00Added an answer on May 26, 2026 at 2:03 pm

    It looks like that you have not initialized the parent class, in your controllers constructor, call the parent constructor as well:

    class Worker extends MY_Controller {
    
        public function __construct() {
            parent::__construct();
            if(php_sapi_name() !== 'cli') {
                show_404();
            }
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a CodeIgniter project. I want to use Memcache, but I don't want
I'm currently working on a project with Codeigniter. I have one controller called Cat
I have a project in Codeigniter, managed via Git and Github, that consists of
I have a codeigniter code that is working on local Apache installation. But it
I have this function on my controller (Im using CodeIgniter) that reads the database,
I have a project that I am developing built off CodeIgniter. The main part
I am trying to code my first codeigniter project. I have a login controller
I want to use codeigniter for an ecommerce project I'm working on but I
I have been using the CodeIgniter system for a while now - but it
I have switched on the Codeigniter profile (very useful) and I have noticed that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.