1

I am getting error in my codeignitor application:

Unable to load the requested file: helpers/files_helper.php

Can you please elaborate where is the issue?

File: autoload.php

<?php
defined('BASEPATH') or exit('No direct script access allowed');

/*
| -------------------------------------------------------------------
| Instructions
| -------------------------------------------------------------------
|
| These are the things you can load automatically:
|
| 1. Packages
| 2. Libraries
| 3. Drivers
| 4. Helper files
| 5. Custom config files
| 6. Language files
| 7. Models
|
*/

/*
| -------------------------------------------------------------------
|  Auto-load Packages
| -------------------------------------------------------------------
| Prototype:
|
|  $autoload['packages'] = array(APPPATH.'third_party', '/usr/local/shared');
|
*/
$autoload['packages'] = array();

/*
| -------------------------------------------------------------------
|  Auto-load Libraries
| -------------------------------------------------------------------
| These are the classes located in system/libraries/ or your
| application/libraries/ directory, with the addition of the
| 'database' library, which is somewhat of a special case.
|
| Prototype:
|
|   $autoload['libraries'] = array('database', 'email', 'session');
|
| You can also supply an alternative library name to be assigned
| in the controller:
|
|   $autoload['libraries'] = array('user_agent' => 'ua');
*/
$autoload['libraries'] = array( 'database', 'user_agent', 'image_lib', 'encryption', 'object_cache', 'email', 'app', 'gateways/app_gateway', 'sms' );

$CI = &get_instance();

$CI->load->helper('files');
$gateways = list_files(APPPATH.'/libraries/gateways');

foreach ($gateways as $gateway) {
    $pathinfo =  pathinfo($gateway);
    // Check if file is .php and do not starts with .dot
    // Offen happens Mac os user to have underscore prefixed files while unzipping the zip file.
    if ($pathinfo['extension'] == 'php' && 0 !== strpos($gateway, '.') && $pathinfo['filename'] != 'App_gateway') {
        array_push($autoload['libraries'], 'gateways/'.strtolower($pathinfo['filename']));
    }
}
/*
| -------------------------------------------------------------------
|  Auto-load Drivers
| -------------------------------------------------------------------
| These classes are located in system/libraries/ or in your
| application/libraries/ directory, but are also placed inside their
| own subdirectory and they extend the CI_Driver_Library class. They
| offer multiple interchangeable driver options.
|
| Prototype:
|
|   $autoload['drivers'] = array('cache');
*/
$autoload['drivers'] = array('session');

/*
| -------------------------------------------------------------------
|  Auto-load Helper Files
| -------------------------------------------------------------------
| Prototype:
|
|   $autoload['helper'] = array('url', 'file');
*/
$autoload['helper'] = array(
        'url',
        'file',
        'form',
        'action_hooks',
        'general',
        'misc',
        'func',
        'datatables',
        'custom_fields',
        'defaults',
        'merge_fields',
        'app_html',
        'email_templates',
        'invoices',
        'estimates',
        'credit_notes',
        'proposals',
        'projects',
        'tasks',
        'fields',
        'tickets',
        'relation',
        'tags',
        'pdf',
        'clients',
        'database',
        'upload',
        'sales',
        'themes',
        'theme_style',
        'pre_query_data_formatters',
        'widgets',
        'sms',
        'deprecated',
    );

if (file_exists(APPPATH.'helpers/system_messages_helper.php')) {
    array_push($autoload['helper'], 'system_messages');
}

if (file_exists(APPPATH.'helpers/my_functions_helper.php')) {
    array_push($autoload['helper'], 'my_functions');
}
/*
| -------------------------------------------------------------------
|  Auto-load Config files
| -------------------------------------------------------------------
| Prototype:
|
|   $autoload['config'] = array('config1', 'config2');
|
| NOTE: This item is intended for use ONLY if you have created custom
| config files.  Otherwise, leave it blank.
|
*/
$autoload['config'] = array();

/*
| -------------------------------------------------------------------
|  Auto-load Language files
| -------------------------------------------------------------------
| Prototype:
|
|   $autoload['language'] = array('lang1', 'lang2');
|
| NOTE: Do not include the "_lang" part of your file.  For example
| "codeigniter_lang.php" would be referenced as array('codeigniter');
|
*/
$autoload['language'] = array('english');

/*
| -------------------------------------------------------------------
|  Auto-load Models
| -------------------------------------------------------------------
| Prototype:
|
|   $autoload['model'] = array('first_model', 'second_model');
|
| You can also supply an alternative model name to be assigned
| in the controller:
|
|   $autoload['model'] = array('first_model' => 'first');
*/
$autoload['model'] = array( 'misc_model' , 'roles_model' , 'clients_model' , 'tasks_model' );

if(file_exists(APPPATH.'config/my_autoload.php')){
    include_once(APPPATH.'config/my_autoload.php');
}

The path in my codeigitor application of this file is application/config/autoload.php I'm just trying to login from the base URL: http://crm.thecoder.pw/ And I'm getting this error: Unable to load the requested file: helpers/files_helper.php

Abdulla Nilam
  • 29,776
  • 14
  • 53
  • 77
Waseem Khan
  • 11
  • 1
  • 4

5 Answers5

3

There is no helper call files_helper. Use file

$this->load->helper('file');

or in /config/autoload.php

$autoload['helper'] = array('file');

EDIT 01

If you're creating new helper check this answer as well

Abdulla Nilam
  • 29,776
  • 14
  • 53
  • 77
2

My solution was to move my custom_helper.php from application/helpers/custom_helper.php to system/helpers/custom_helper.php and in application/config/autoload.php $autoload['helper'] = array('custom');

Reload page and it work fine

ShapCyber
  • 2,754
  • 1
  • 18
  • 24
1

I think you have created helper in application/helpers folder.
You have to create helper in system/helpers folder instead of application/helpers.
Then load $this->load->helper('files');

סטנלי גרונן
  • 2,740
  • 21
  • 43
  • 62
Poonam Navapara
  • 186
  • 1
  • 8
1

There should not be an upper case latter in helpers name.

Rizwan Ansar
  • 416
  • 7
  • 13
0

I think it's a simple mistake that you have made, Replace below line of your code

$CI->load->helper('files');

by

$CI->load->helper('file');
Poonam Navapara
  • 186
  • 1
  • 8