Codeigniter DB Language extension not working - php

I'm trying to use this extension
But it gives me the following error when loading the library:
Unable to load the requested class: Language
Also if I write MY_Language instead, it gives me the following error:
Fatal error: Class 'CI_Language' not found in C:\wamp\www\ckphp\application\libraries\MY_Language.php on line 79
I am using WAMP and CI v. 2.2.0
Thanks!

I figured it out myself after some more researching...
Apparently the language class is not even in the library folder, but in core folder, meaning it should be placed in the core application/core folder. Also the name is not CI_Language, but CI_Lang, meaning the file name has to be MY_Lang (if MY_ is your prefix). The last thing to change in the extension is
parent::CI_Language();
to
parent::__construct();
and everything should work fine!
Usage:
$this->lang->load('set', 'language'); // To load a language
$this->lang->line('key'); // to display the text
or simply
lang('key'); // if using the language helper
Hope this will help others in the future!

I made a GIST for latest CodeIgniter 3.1.X including with migration to create the database structure
https://gist.github.com/cyberfly/885b320fdf914ae15f7316b22cc72f32

Related

Non Existent Class Error in codeigniter

I'm using codeigniter.Now I am upgrading CodeIgniter from 2.2.0 to 3.0.0
I need to use PhpExcel.But it shows an error like Non-existent class: CI_Excel
Please anyone help me.
The system/ directory is reserved for CI, you're not supposed to modify or put anything in there.
Any custom libraries you use should go into application/libraries/.
change the library name As CI_Ex.... and save it on libraries folder

CodeIgniter PHPWord template not found

I'm facing trouble when using PHPWord with CodeIgniter in loadTemplate always return error "Template Not Found".
I'm using phpword in third party and create Word.php class in library to call it.
My CodeIgniter not a pure one. It already injected like some homemade cms from previous programmer.
My Question is how to I know where is the path of loadTemplate?
Any info needed you can ask me I will provide for you
Thanks,
Hendra
I'm not sure if I understood your scenario, but in any case there is no magic in how the path of loadTemplate works - it works exactly the same as you would access any file with php, i.e. either you place your template file under the phpunit library and use a relative path or you place your file somewhere else and use a full path (or some alias if you have some defined in your server (apache/nginx/..) configuration).

Codeigniter 3 dev Unable to load the requested class

I'm new in CI and now I'm trying to use CodeIgniter 3 to develop my site. I just only extract the framework and change only one think in config/autoload.php file:
$autoload['libraries'] = array('database','input');
when I run the site, an error occur:
Unable to load the requested class: Input
When I tried it with CI version 2.2.0 stable, every thing is OK, no errors
Could some one explain why and help me to solve it?
As of documentation input library is loaded by default.
This class (input) is initialized automatically by the system so there is no need to do it manually.
Autoloading documentation http://www.codeigniter.com/userguide3/general/autoloader.html
By default the library load from system/core folder in you CI. But the Input library is located on the core folder so you need to give relative path to the Input.php like this
$autoload['libraries'] = array('database','../core/input');

how to require_once in codeigniter

I am trying to extend a library in codeigniter. The only way to do so seems to include the original library using require_once then load the extended library using $this->load->library()
right now I have tried
require_once('ion_auth.php');
require_once('home/SITE_NAME/public_html/FOLDER_NAME/application/libraries/ion_auth.php')
require_once('/home/SITE_NAME/public_html/FOLDER_NAME/application/libraries/ion_auth.php')
but unfortunately not luck..... I keep getting this error
Message: require_once(...) [function.require-once]: failed to open stream: No such file or directory
Weird thing is though this works on my local xampp environment but not on the actual server.
Use CodeIgniter's built in constant, APPPATH
require_once(APPPATH.'libraries/ion_auth.php');
If the library is a codeigniter specific library, as sbaaaang points out, you should use:
$this->load->library('ion_auth');
However, if the library is just a generic PHP class or set of functions, the codeiginter loader may not recognize it. Then you will need to use either one of the generic loading operators (include, include_once, require, require_once), with the APPPATH constant, as also pointed out:
require_once(APPPATH.'libraries/ion_auth.php');
Do you know that Codeigniter has a loader class?
change this
require_once('/home/SITE_NAME/public_html/FOLDER_NAME/application/libraries/ion_auth.php')
to
$this->load->library('ion_auth');
and be sure your libraries/ion_auth.php file it's a class named `class ion_auth{}`

blank page opening after uploading codeigniter code to server

I have uploaded Codeigniter code to server but blank page is displayed when opening the URL
I am using codeingniter 2.1.3.
I used MY_Controller.php on application/core/ folder as per specification
I got error in error_log file of codeigniter
"PHP Fatal error: Class 'My_Controller' not found in /home/nesterin/public_html/realstate/application/controllers/administrator/login.php on line 3"
can you tell what i am doing wrong ?
I'm not familiar with codeignighter. But I think if your class name is My_Controller and it's filename is MY_Controller.php autoloader probably won't find the file on a case sensitive file system.
When you upload you need to check these steps:
Change Config file. New versions of CI you can let it blank. CHECK base_url PLEASE! Read documentation
Change database.php and add new data for database. Read Documentation
If you use the MY_Controller, than you need to check if you have the file in core folder and if you extend it correct in Controller too.
Hope that this answer will help you. If you face any problem, comment please!

Categories