Question

I have searching for a solution for this one but nothing seems to work for me, the deal is that I have already use require_once in other project with the same library (PHPExcel) and worked very well, but now I don't know what's wrong.

I'm using CodeIgniter in both projects but I can't figure out if it's PHP version problem or if Im doing something wrong. So, here's the code:

$this->load->library('PHPExcel');
require_once (base_url().'applications/proyect/libraries/PHPExcel/Cell/AdvancedValueBinder.php');

and this is displayed:

A PHP Error was encountered

Severity: Warning

Message: Users::require_once(http://localhost/my_proyect/applications/proyect/libraries/PHPExcel/Cell/AdvancedValueBinder.php) [function.Usuarios-require-once]: failed to open stream: 
An error occurred during the connection attempt because the connected party did not properly respond after a period of time, or there was an error in the connection established because connected host has failed to respond

Fatal error: Users::require_once() [function.require]: 
Failed opening required 'http://localhost/my_proyect/applications/proyect/libraries/PHPExcel/Cell/AdvancedValueBinder.php' (include_path='.;C:\php5\pear'

I'm not sure what's the C:\php5\pear thing, but I can't handle with this require_once problem.

Was it helpful?

Solution

Try to use codeigniter in correct way.

SUGGESTION: Since it is a library you don't have to include it precisely. Move the library file to applications/libraries directory and -


1) You can autoload it in config/autoload.php

$autoload['libraries'] = array('my_library');


2) Or you can specifically load into your required controller

<?php
class Something extends MY_Controller
{
    public function __construct()
   {
        parent::__construct();
        $this->load->library('my_library');
   }

   public function my_function()
   {
        ...
   }
}

OTHER TIPS

You are trying to require a file over an HTTP connection, and the connection failed. You should require the file using the disk path wherever possible.

You can't use

base_url();

You can use

APPPATH

it's constant

   require_once(APPPATH.'applications/proyect/libraries/PHPExcel/Cell/AdvancedValueBinder.php');
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top