codeigniter4projects / website-old

Old CodeIgniter Website
MIT License
49 stars 27 forks source link

Can't run site #57

Closed PwrSrg closed 3 years ago

PwrSrg commented 4 years ago

Either there is something messed up with this repo, or I am doing something completely wrong.

I have been trying to get this running on my local machine for a few days now, and all I can ever get is a "Whoops!" error message. I have tried many different methods on two different machines.

Here is how to reproduce the issue:

git clone https://github.com/codeigniter4projects/website2
cd website2
composer install
composer update
php spark serve
http://localhost:8080

Whoops!

Here is what shows up in the Log File: CRITICAL - 2020-07-07 22:57:03 --> Request URI segment is our of range: 1

0 C:\Users\SergiHome\www\website2\vendor\codeigniter4\framework\system\HTTP\URI.php(485): CodeIgniter\HTTP\Exceptions\HTTPException::forURISegmentOutOfRange(1)

1 C:\Users\SergiHome\www\website2\app\Controllers\BaseController.php(67): CodeIgniter\HTTP\URI->getSegment(1)

2 C:\Users\SergiHome\www\website2\app\Controllers\Home.php(99): App\Controllers\BaseController->render('welcome')

3 C:\Users\SergiHome\www\website2\vendor\codeigniter4\framework\system\CodeIgniter.php(914): App\Controllers\Home->index()

4 C:\Users\SergiHome\www\website2\vendor\codeigniter4\framework\system\CodeIgniter.php(400): CodeIgniter\CodeIgniter->runController(Object(App\Controllers\Home))

5 C:\Users\SergiHome\www\website2\vendor\codeigniter4\framework\system\CodeIgniter.php(308): CodeIgniter\CodeIgniter->handleRequest(NULL, Object(Config\Cache), false)

6 C:\Users\SergiHome\www\website2\public\index.php(45): CodeIgniter\CodeIgniter->run()

7 C:\Users\SergiHome\www\website2\vendor\codeigniter4\framework\system\Commands\Server\rewrite.php(34): require_once('C:\Users\SergiH...')

8 {main}

What am I missing???

lonnieezell commented 4 years ago

What version of PHP are you running? Is it at least 7.2?

lonnieezell commented 4 years ago

Ah - found the missing steps.

CI_ENVIRONMENT = development
MOCK_MYBB = true

The environment line will show errors, etc. The MOCK_MYBB will not try to connect to an existing MyBB installation, which is probably what you need for local development.

This all works for me on PHP 7.2.

PwrSrg commented 4 years ago

I had tried that too, but I basically get the same error, just without the "Whoops!".

CodeIgniter\HTTP\Exceptions\HTTPException
Request URI segment is our of range: 1

PHP 7.3.11

ci4 website2 error 01.zip

lonnieezell commented 4 years ago

Strange. When I ran it I was using the built in php spark serve. Are you using it under Apache or something else? If so, you might try using the built-in server.

PwrSrg commented 4 years ago

Yes, as originally stated, I am using php spark serve. Here is a video of the entire process from start to finish:

https://youtu.be/bEKpvSs5hlc

lonnieezell commented 4 years ago

Sorry forgot that. Unfortunately I don't have an answer. And I don't have a Windows dev box up and running currently so I cannot recreate it. Any help you could give by debugging it would be helpful, though.

I would guess a first step might be to try using different values for $uriProtocol to see if that changes anything. Changing it to PATH_INFO might help? Taking a stab in the dark here. Sorry.

michalsn commented 4 years ago

Controllers\BaseController::render() - adding $this->request->uri->setSilent() in the first line should fix it.