CodeIgniter Forums

Full Version: Load a class in CodeIgniter
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello Community,

I am having a problem in loading a class in CodeIgniter. Hope you can help me with this! Smile

Here is the scenario.

Before I am using Composer to load packages/classes in my project. Very helpful. Makes my life easy.

But suddenly, I cannot install packages. It shows zlib_decode data error. I don't what really happened.
I am still looking for a solution but for now, I just want to load a package in my project. 

The package is the phpoffice/phpspreadsheet.[url=https://packagist.org/packages/phpoffice/phpspreadsheet][/url]

My question is: how can I include this package/class in my project? So I can call/instantiate the Spreadsheet class.
$spreadsheet = new Spreadsheet();

I have tried putting it in application/libraries and application/third_party folder. I also have tried using require_once APPPATH . '..'


Still I cant instantiate the Spreadsheet class.

Would you guide me how to properly load a class in CodeIgniter? THANKS! Smile
(01-03-2018, 01:50 AM)danangeloalcanar Wrote: [ -> ]Hello Community,

I am having a problem in loading a class in CodeIgniter. Hope you can help me with this! Smile

Here is the scenario.

Before I am using Composer to load packages/classes in my project. Very helpful. Makes my life easy.

But suddenly, I cannot install packages. It shows zlib_decode data error. I don't what really happened.
I am still looking for a solution but for now, I just want to load a package in my project. 

The package is the phpoffice/phpspreadsheet.[url=https://packagist.org/packages/phpoffice/phpspreadsheet][/url]

My question is: how can I include this package/class in my project? So I can call/instantiate the Spreadsheet class.
$spreadsheet = new Spreadsheet();

I have tried putting it in application/libraries and application/third_party folder. I also have tried using require_once APPPATH . '..'


Still I cant instantiate the Spreadsheet class.

Would you guide me how to properly load a class in CodeIgniter? THANKS! Smile

Use Composer:

https://www.codeigniter.com/user_guide/g...-resources
(01-03-2018, 02:05 AM)Paradinight Wrote: [ -> ]
(01-03-2018, 01:50 AM)danangeloalcanar Wrote: [ -> ]Hello Community,

I am having a problem in loading a class in CodeIgniter. Hope you can help me with this! Smile

Here is the scenario.

Before I am using Composer to load packages/classes in my project. Very helpful. Makes my life easy.

But suddenly, I cannot install packages. It shows zlib_decode data error. I don't what really happened.
I am still looking for a solution but for now, I just want to load a package in my project. 

The package is the phpoffice/phpspreadsheet.[url=https://packagist.org/packages/phpoffice/phpspreadsheet][/url]

My question is: how can I include this package/class in my project? So I can call/instantiate the Spreadsheet class.
$spreadsheet = new Spreadsheet();

I have tried putting it in application/libraries and application/third_party folder. I also have tried using require_once APPPATH . '..'


Still I cant instantiate the Spreadsheet class.

Would you guide me how to properly load a class in CodeIgniter? THANKS! Smile

Use Composer:

https://www.codeigniter.com/user_guide/g...-resources

Hi Paradinight,

As I have said on my post, I am having a problem with composer. I am still trying to fix it. But for now, is there a way to include packages without using composer? Thanks!
(01-03-2018, 02:40 AM)danangeloalcanar Wrote: [ -> ]
(01-03-2018, 02:05 AM)Paradinight Wrote: [ -> ]
(01-03-2018, 01:50 AM)danangeloalcanar Wrote: [ -> ]Hello Community,

I am having a problem in loading a class in CodeIgniter. Hope you can help me with this! Smile

Here is the scenario.

Before I am using Composer to load packages/classes in my project. Very helpful. Makes my life easy.

But suddenly, I cannot install packages. It shows zlib_decode data error. I don't what really happened.
I am still looking for a solution but for now, I just want to load a package in my project. 

The package is the phpoffice/phpspreadsheet.[url=https://packagist.org/packages/phpoffice/phpspreadsheet][/url]

My question is: how can I include this package/class in my project? So I can call/instantiate the Spreadsheet class.
$spreadsheet = new Spreadsheet();

I have tried putting it in application/libraries and application/third_party folder. I also have tried using require_once APPPATH . '..'


Still I cant instantiate the Spreadsheet class.

Would you guide me how to properly load a class in CodeIgniter? THANKS! Smile

Use Composer:

https://www.codeigniter.com/user_guide/g...-resources

Hi Paradinight,

As I have said on my post, I am having a problem with composer. I am still trying to fix it. But for now, is there a way to include packages without using composer? Thanks!

Try
composer clear-cache
and/or
composer self-update --update-keys

it could be slow internet

---
you need an autoloader. :/
we should solve the composer problem.
(01-03-2018, 03:40 AM)Paradinight Wrote: [ -> ]
(01-03-2018, 02:40 AM)danangeloalcanar Wrote: [ -> ]
(01-03-2018, 02:05 AM)Paradinight Wrote: [ -> ]
(01-03-2018, 01:50 AM)danangeloalcanar Wrote: [ -> ]Hello Community,

I am having a problem in loading a class in CodeIgniter. Hope you can help me with this! Smile

Here is the scenario.

Before I am using Composer to load packages/classes in my project. Very helpful. Makes my life easy.

But suddenly, I cannot install packages. It shows zlib_decode data error. I don't what really happened.
I am still looking for a solution but for now, I just want to load a package in my project. 

The package is the phpoffice/phpspreadsheet.[url=https://packagist.org/packages/phpoffice/phpspreadsheet][/url]

My question is: how can I include this package/class in my project? So I can call/instantiate the Spreadsheet class.
$spreadsheet = new Spreadsheet();

I have tried putting it in application/libraries and application/third_party folder. I also have tried using require_once APPPATH . '..'


Still I cant instantiate the Spreadsheet class.

Would you guide me how to properly load a class in CodeIgniter? THANKS! Smile

Use Composer:

https://www.codeigniter.com/user_guide/g...-resources

Hi Paradinight,

As I have said on my post, I am having a problem with composer. I am still trying to fix it. But for now, is there a way to include packages without using composer? Thanks!

Try
composer clear-cache
and/or
composer self-update --update-keys

it could be slow internet

---
you need an autoloader. :/
we should solve the composer problem.

Hi Paradinight,


Thanks for your suggestion. You are right there is a problem in the internet or network I am connected to. In our company we have a firewall. I am sure that is the reason why I cannot use Composer in the office. I tried to do install the package at home, and it works perfectly. The company firewall is blocking incoming http connections. Thanks!