Welcome Guest, Not a member yet? Register   Sign In
CI 3.1.2 Unable to load any controller but default
#1

Hi all,

I've been using CI 2.0 for a long time, but now that I have a new project I'd like to move to CI 3.0. I've downloaded and installed CI 3.1.2 and the welcome controller loads properly if I write:

http://example.com

Sadly, if I try to load it this way it fails:

http://example.com/index.php/welcome

So does all controllers I've tried to create. For instance I've created the following controller in the application/controllers/Test.php file:

Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

    class Test extends CI_Controller
    {

        public function index()
        {
            echo "OK";
        }

    }

It doesn't load using:

http://example.com/index.php/test

But if I change default controller from "welcome" to "test" then it returns OK properly if I browse to:

http://example.com/

Also, if I run it from the CLI it works properly and again returns OK, no matter if is set as default of not:

Code:
php index.php test

I have tried to change $config['uri_protocol'] to QUERY_STRING and PATH_INFO without succes, I've tried to change base_url so its value is 'http://example.com/' instead of empty.

Server is a Raspberry Pi 2 using raspbian:

Code:
Linux raspberrypi 4.1.19-v7+ #858 SMP Tue Mar 15 15:56:00 GMT 2016 armv7l GNU/Linux

This is php version:

Code:
PHP 5.4.45-0+deb7u5 (cli) (built: Sep 18 2016 17:23:08)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2014 Zend Technologies

I hope someone can help :-)
Reply
#2

change
public function index()
to
public function test()
Reply
#3

(11-07-2016, 08:17 AM)andersonunsonst Wrote: change
public function index()
to
public function test()

No.
Reply
#4
Wink 

(11-07-2016, 08:17 AM)andersonunsonst Wrote: change
public function index()
to
public function test()

That would convert the function in the class constructor AFAIK. I have tried anyway and nothing changes.

Thanks for trying though Smile
Reply
#5

I have just done the same using a fresh install of CI 3.1.2. It happens the same, http://example.com/ loads the welcome controller but http://example.com/index.php/welcome returns "not found"
Reply
#6

CodeIgniter Users Guide: PHP version 5.6 or newer is recommended.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#7

(11-07-2016, 03:14 PM)InsiteFX Wrote: CodeIgniter Users Guide: PHP version 5.6 or newer is recommended.

How is that related to the topic?
Reply
#8

(11-07-2016, 03:53 AM)utodev Wrote: Hi all,

I've been using CI 2.0 for a long time, but now that I have a new project I'd like to move to CI 3.0. I've downloaded and installed CI 3.1.2 and the welcome controller loads properly if I write:

http://example.com

Sadly, if I try to load it this way it fails:

http://example.com/index.php/welcome

So does all controllers I've tried to create. For instance I've created the following controller in the application/controllers/Test.php file:

Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

   class Test extends CI_Controller
   {

       public function index()
       {
           echo "OK";
       }

   }

It doesn't load using:

http://example.com/index.php/test

But if I change default controller from "welcome" to "test" then it returns OK properly if I browse to:

http://example.com/

Also, if I run it from the CLI it works properly and again returns OK, no matter if is set as default of not:

Code:
php index.php test

I have tried to change $config['uri_protocol'] to QUERY_STRING and PATH_INFO without succes, I've tried to change base_url so its value is 'http://example.com/' instead of empty.

Server is a Raspberry Pi 2 using raspbian:

Code:
Linux raspberrypi 4.1.19-v7+ #858 SMP Tue Mar 15 15:56:00 GMT 2016 armv7l GNU/Linux

This is php version:

Code:
PHP 5.4.45-0+deb7u5 (cli) (built: Sep 18 2016 17:23:08)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2014 Zend Technologies

I hope someone can help :-)

What do you use as webserver and how is it connected to php?

eg. apache and php-fpm



make a script eg. test.php

Code:
<?php
var_dump( $_SERVER['REQUEST_URI']);
var_dump( $_SERVER['QUERY_STRING']);
var_dump( $_SERVER['PATH_INFO']);

call it like "test.php/welcome" and post the result
Reply
#9

(11-07-2016, 03:16 PM)Narf Wrote:
(11-07-2016, 03:14 PM)InsiteFX Wrote: CodeIgniter Users Guide: PHP version 5.6 or newer is recommended.

How is that related to the topic?

Because the Users Guide states that:

It should work on 5.3.7 as well, but we strongly advise you NOT to run such old versions of PHP, because of potential security and performance issues, as well as missing features.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#10

(11-07-2016, 09:46 PM)Paradinight Wrote:
Code:
<?php
var_dump( $_SERVER['REQUEST_URI']);
var_dump( $_SERVER['QUERY_STRING']);
var_dump( $_SERVER['PATH_INFO']);

call it like "test.php/welcome" and post the result

I've tried this and I also get a not found error, but if I just run test.php it returns data in the REQUEST_URI value (QUERY_STRING is an empty string and PATH_INFO is NULL).

It seems php is connected cause it runs (and otherwise the welcome controller won't work either) but there must be something in the Apache configuration, I'll check. Thanks I hope this leads me through the good track :-)
Reply




Theme © iAndrew 2016 - Forum software by © MyBB