localhost is currently unable to handle this request. codeigniter problem - codeigniter

I have this error when i am trying to access a website from wamp, it is done in codeigniter.
Error:
localhost is currently unable to handle this request. HTTP ERROR 500
homeindex controller
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class HomeIndex extends CI_Controller {
public function __construct(){
parent:: __construct();
$this->load->helper('html');
$this->load->helper('form','url','file');
$this->load->library('session','upload');
}
public function index()
{
//$this->load->view('coming_soon');
$this->load->view('homeIndex');
}
}
route
$route['default_controller'] = 'HomeIndex';
$route['404_override'] = '';
$route['translate_uri_dashes'] = FALSE;
I am able to access other website which are not done using any frameworks.
This website is done using codeigniter. I am not able to access the website.
Can anyone tell me what is the problem?

Multiple loads with one call are done using an array:
$this->load->helper(array('form','url','file'));
$this->load->library(array('session','upload'));
https://www.codeigniter.com/user_guide/libraries/loader.html#CI_Loader::helper
if that doesn't work turn on error reporting (switch to development mode in index.php) and see what the actual error is. 500 error can be many things...

Related

Returns 404 even if MVC files are setup properly in Codeigniter

My code igniter project is returning 404 whenever I use method that I created in controllers. I have it running on Mac OS Mojave on Apache2.
There might be configuration or setting that I missed.
The codeigniter page works fine when opening http://localhost/myproject where I see the welcome page.
I have a 404 problem when I start using the new controller class. To make it simple, I created below "Pages.php" controller file inside application/controllers folder:
<?php
class Pages extends CI_Controller {
public function view()
{
echo "running the view method";
}
}
I expected the page to display "running the view method"
but the result is a 404 page at http://localhost/myproject/view or http://localhost/myproject/index.php/view.
it works by adding below in route.php
$route['(:any)'] = 'pages/$1';

Why 404 Page Not Found error occurs except default controller

I am using OS Ubuntu.
I am creating the application on codeigniter and facing problem while I am running my code. Only default controller is working, other then that are not working and application through the error:
404 Page Not Found
The page you requested was not found.
Code: Controller Name: Test
defined('BASEPATH') OR exit('No direct script access allowed');
class Test extends CI_Controller {
public function index()
{
echo "Hi this is Test Controller";
}
}
There may be many reason where CI can display 404 Page Not Found.
As example
If the File does not exists in your controller folder.
If you using CI-3 in that case File name and class name should be same and UCfirst.So your controller file name should be Test.php not test.php.
If your url is not valid. like you using link without index.php but you did not do steps to work without it(.htaccess,..).
Note:
Try to use your link http://your_site_base_url/index.php/test if it does not work means you have any of those problem.

Why wont my Codeigniter model load on Lamp?

My model is:
/application/models/tester.php
The code inside is:
class Tester extends CI_Model
{
function __construct()
{
parent::__construct();
$this->load->database();
}
}
And here's the usage:
class Hauth extends CI_Controller
{
public function index()
{
$this->load->view('hauth/home');
}
public function login($provider)
{
// Load models
$this->load->model('Tester');
// Load helpers
$this->load->helper('url');
log_message('debug', "controllers.HAuth.login($provider) called");
It works perfectly on my local WAMP server but I get this error on the LAMP production envrionment:
An Error Was Encountered
Unable to locate the model you have specified: Tester
I've looked at a dozen StackOverflow questions that appear to be similar but I've tried all of the solutions posted. As far as I can tell, I've followed the CI manual to the letter. I figured that perhaps file names were an issue WAMP vs LAMP so I confirmed the case of the file names via FTP. Thought it might be a naming conflict, so I renamed them "tester". Again, works perfect on local, but not on live.
I found the problem. Turns out I accidentally used a zip of Codeigniter 3.0-dev. When I moved my application files over to the latest stable version, everything instantly worked.

google calendar with codeigniter

I'm trying to integrate Google Calendar in my php application (I use CodeIgniter for this).
I have a problem with my controller calendar.php.
<?php
session_start();
Class Calendar extends Controller {
function Calendar(){
echo 'start';
parent::Controller();
echo 'okkkkkkkk';
require_once '/home/me/framework/ZendGdata/library/Zend/Loader.php';
Zend_Loader::loadClass('Zend_Gdata');
Zend_Loader::loadClass('Zend_Gdata_AuthSub');
Zend_Loader::loadClass('Zend_Gdata_ClientLogin');
Zend_Loader::loadClass('Zend_Gdata_Calendar');
}
but there is a problem with parent::Controller() because 'okkkkkk' is not printed.
Could anyone help me please?
Change
parent::Controller();
to
parent::__construct();
parent::Controller() doesn't work in CI because as of CI 2.1.2, the constructors are declared using PHP's __construct() method.
As a sidenote, it seems you are using an older version of CI. CI 2.o onwards, the base controller class is called CI_Controller as opposed to just Controller. You should look into updating your project by replacing the system folder.
You can find the full working code in this following link https://github.com/omerkamcili/ci_google_calendar_api.
After down loading the code create your service account, OAuth client Id's in the following link http://console.developers.google.com.
Then replace the client_id,client_secret,redirect_uri's in your project file in the following path -> /project_folder/application/config/client_secret_846685841138-t0a5b9d2i655e7km54md8j440jcg5rr5.apps.googleusercontent.com.json file
Finally download and replace the google-api-php-client in the following file path /project_folder/application/third_party/google-api-php-client

CodeIgniter 2.0 with Modular Extensions (HMVC) not showing anything in Linux

*edited to be more clearly
I'm deploying CI 2.0.3 with Modular Extensions (HMVC) in two environments, one is Windows -for development- and the other is Linux -for production-. Both environment has identically folders and files structure. Currently I am having a problem.
After integrating the Modular Extensions to CI by following the manual. The first thing I did was moving the default Welcome MVC that comes with CI to Modular Extensions HMVC. Both environment successfully moved and can be viewed on the browser.
But when I create other modules, it worked on Windows environment but not on Linux. On Windows when I call the module the browser shows the page as expected. But on Linux it shows just white blank page. Not even an 404 err page, which means it is not a broken link.
Can anyone tells me what is wrong in the CI?
Directory structure
/application
-/cache
-/config
-/controllers
-/core
--MY_Loader.php
--MY_Router.php
-/errors
-/helpers
-/hooks
-/language
--/english
-/libraries
-/logs
-/models
-/modules
--/csv_game_credit
---/controllers
----csv_game_credit.php
---/models
----csv_game_credit_db.php
---/views
----welcome_message.php
--/welcome
---/controllers
----welcome.php
---/views
----welcome_message.php
-/third_party
--/MX
--Base.php
--Ci.php
--Config.php
--Controller.php
--Lang.php
--Loader.php
--Modules.php
--Router.php
-/views
Welcome controller
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Welcome extends CI_Controller {
public function index()
{
$this->load->view('welcome_message');
}
}
Csv_game_credit controller
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Csv_game_credit extends CI_Controller {
function __construct() {
parent::__construct();
$this->load->model('Csv_game_credit_db');
$this->load->dbutil();
$this->load->helper('file');
}
public function index()
{
$this->load->view('welcome_message');
}
}
Is this has something to do with the Linux's folder permission? I will try to change the folder permission to 777 and update you guys
Thanks before
You need to extend MX_Controller not CI_Controller
If you are using the HMVC extension from wiredesignz you need to verify that you put the MX folder in the application/third_party folder and the MY_Loader.php and MY_Router.php in the application/core folder.
When this has been verified, create the folder modules in the application folder ('application/modules`).
Now, what is a little tricky about this solution is that when you wan't to create a module, the default controller has to be named the same as the module - the default controller name specified in the config doesn't apply here.
This means that if you create a module called `mymodule', you should create a folder/file structure like this:
application/modules/mymodule
- /controllers
- - mymodule.php
- /views
- - whatever.php
In the controller, located at application/modules/mymodule/controllers/mymodule.php you just create a controller as you would normally do:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Mymodule extends CI_Controller {
public function index()
{
$this->load->view('whatever');
}
}

Resources