Welcome Guest, Not a member yet? Register   Sign In
Errors In Code
#1

(This post was last modified: 08-21-2017, 06:40 AM by SDavisworth.)

Hello all... Last week I was getting "Fatal error: Cannot use Config\Services as Services because the name is already in use in..." was advised as follows: we've found that PHP versions under 7.0.15 (especially on Windows) have a problem. Upgrade your PHP version and try again.

I upgraded to PHP 7.1.8 and the error was resolved. I've been following the tutorial posted at https://bcit-ci.github.io/CodeIgniter4/t...pages.html but seem to get "404 - File Not Found Controller or its method is not found" no matter what I do. I've kept everything as downloaded apart from editing my baseURL as prescribed and implemented the tutorial controllers and views etc.

I then thought to try the "News" tutorial with pretty much the same results. No matter what i "Tweak" i can't get the code to work

I was wondering why I'm getting this. .... any suggestions? and could it possibly be caused by PHP version being untested at V7.1.8?

Apologies if I've posted to the incorrect forum
Reply
#2

Did you set your path in the ./application/Config/Paths.php file?

I am running Windows 10 Pro with PHP version 7.1.8 and everything runs fine.

You may have to add environment variables in Windows Control Panel.
What did you Try? What did you Get? What did you Expect?

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

(08-21-2017, 05:39 AM)SDavisworth Wrote: Hello all... Last week I was getting "Fatal error: Cannot use Config\Services as Services because the name is already in use in..." was advised as follows: we've found that PHP versions under 7.0.15 (especially on Windows) have a problem. Upgrade your PHP version and try again.

I upgraded to PHP 7.1.8 and the error was resolved. I've been following the tutorial posted at https://bcit-ci.github.io/CodeIgniter4/t...pages.html but seem to get "404 - File Not Found Controller or its method is not found" no matter what I do. I've kept everything as downloaded apart from editing my baseURL as prescribed and implemented the tutorial controllers and views etc.

I then thought to try the "News" tutorial with pretty much the same results. No matter what i "Tweak" i can't get the code to work

I was wondering why I'm getting this. .... any suggestions? and could it possibly be caused by PHP version being untested at V7.1.8?

Apologies if I've posted to the incorrect forum

first download a recent commit, secondly "haven't really used the docs" the docs are still been updated. not every thing there are correct.
Reply
#4

//use Config\Services;
will be ok.
Reply
#5

(08-21-2017, 10:54 AM)ubiray Wrote: //use Config\Services;
will be ok.

Will be ok until you try to use that file for your own application. The bigger thing is to help us determine why this is happening. So far, the common denominator that I've seen has been on Windows, running PHP < 7.0.15.
Reply
#6

(08-21-2017, 05:39 AM)SDavisworth Wrote: Hello all... Last week I was getting "Fatal error: Cannot use Config\Services as Services because the name is already in use in..." was advised as follows: we've found that PHP versions under 7.0.15 (especially on Windows) have a problem. Upgrade your PHP version and try again.

I upgraded to PHP 7.1.8 and the error was resolved. I've been following the tutorial posted at https://bcit-ci.github.io/CodeIgniter4/t...pages.html but seem to get "404 - File Not Found Controller or its method is not found" no matter what I do. I've kept everything as downloaded apart from editing my baseURL as prescribed and implemented the tutorial controllers and views etc.

I then thought to try the "News" tutorial with pretty much the same results. No matter what i "Tweak" i can't get the code to work

I was wondering why I'm getting this. .... any suggestions? and could it possibly be caused by PHP version being untested at V7.1.8?

Apologies if I've posted to the incorrect forum

I'm starting to take a look at the tutorial to get it current again. While there are some capitalization inconsistencies with the view files, the biggest thing is that it isn't currently finding controllers without a namespace it looks like. If you add namespace App\Controllers; to the top of the controllers they should work.
Reply
#7

(This post was last modified: 08-22-2017, 01:18 AM by SDavisworth.)

(08-21-2017, 08:40 AM)InsiteFX Wrote: Did you set your path in the ./application/Config/Paths.php file?

I am running Windows 10 Pro with PHP version 7.1.8 and everything runs fine.

You may have to add environment variables in Windows Control Panel.

Thanks for you suggestion but I left everything as it was... The default "Welcome" page loads fine and all my refs in ./application/Config/Paths.php are...

public $applicationDirectory = '../application';
public $writableDirectory = '../writable';
public $testsDirectory = '../tests';
public $publicDirectory = 'public';

I'm using NetBeans and have copied the CI4 source files to ProjectName..Source Files... so can't really change any paths.
InsiteFX... can you please advise me on what sort of "Windows Env Vars" I would need to apply... I've created other std php apps before and they are running ok... so not sure on what to change. Thanks
Reply
#8

(08-21-2017, 07:00 PM)kilishan Wrote:
(08-21-2017, 05:39 AM)SDavisworth Wrote: Hello all... Last week I was getting "Fatal error: Cannot use Config\Services as Services because the name is already in use in..." was advised as follows: we've found that PHP versions under 7.0.15 (especially on Windows) have a problem. Upgrade your PHP version and try again.

I upgraded to PHP 7.1.8 and the error was resolved. I've been following the tutorial posted at https://bcit-ci.github.io/CodeIgniter4/t...pages.html but seem to get "404 - File Not Found Controller or its method is not found" no matter what I do. I've kept everything as downloaded apart from editing my baseURL as prescribed and implemented the tutorial controllers and views etc.

I then thought to try the "News" tutorial with pretty much the same results. No matter what i "Tweak" i can't get the code to work

I was wondering why I'm getting this. .... any suggestions? and could it possibly be caused by PHP version being untested at V7.1.8?

Apologies if I've posted to the incorrect forum

I'm starting to take a look at the tutorial to get it current again. While there are some capitalization inconsistencies with the view files, the biggest thing is that it isn't currently finding controllers without a namespace it looks like. If you add namespace App\Controllers; to the top of the controllers they should work.

Thanks for response... when following tutorial and going to "http://mysite:8080/index.php/pages/view" I was expecting to see my "Home" page wrapped in my header and footer, but I got 404... 

When adding "namespace App\Controllers;" I get blank page but when viewing source I see html in there that should be displaying... all about errors ... I think associated to the "Debug Bar" I see in Chrome... however when going to "http://mysite:8080/index.php/pages/view/home" I do see home... this is contrary to instructions in the Tutorial as I expected to see view() method was defaulted to $pages = 'home'... or am I missing something?

Once again thanks for efforts
Reply
#9

(This post was last modified: 08-22-2017, 04:28 PM by InsiteFX. Edit Reason: spelling error )

(08-21-2017, 09:40 PM)SDavisworth Wrote:
(08-21-2017, 08:40 AM)InsiteFX Wrote: Did you set your path in the ./application/Config/Paths.php file?

I am running Windows 10 Pro with PHP version 7.1.8 and everything runs fine.

You may have to add environment variables in Windows Control Panel.

Thanks for you suggestion but I left everything as it was... The default "Welcome" page loads fine and all my refs in ./application/Config/Paths.php are...

public $applicationDirectory = '../application';
public $writableDirectory = '../writable';
public $testsDirectory = '../tests';
public $publicDirectory = 'public';

I'm using NetBeans and have copied the CI4 source files to ProjectName..Source Files... so can't really change any paths.
InsiteFX... can you please advise me on what sort of "Windows Env Vars" I would need to apply... I've created other std php apps before and they are running ok... so not sure on what to change. Thanks

I set the variables in the Control Panel to 

Like this Windows 8 and 10:

Code:
C:\xampp\php
C:\xampp\htdocs
C:\ProgramData\ComposerSetup\bin

Like this for Windows 7:

Code:
C:\xampp\php;
C:\xampp\htdocs;
C:\ProgramData\ComposerSetup\bin;

Control Panel:

1) System and Security
2) System
3) On left side click on Advanced system settings
4) On bottom of Dialog click on Environment Variables...
5) Click on Path and then edit them.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply




Theme © iAndrew 2016 - Forum software by © MyBB