Welcome Guest, Not a member yet? Register   Sign In
How debug Tutorial - News section to pass "We seem to have hit a snag. ..."
#1

Hello,
i'm at very first attempt to use PHP and CodeIgniter4 . I have installed Apache2.4 and PHP7.2.22 and set SQLServer on Windows10 and test them all together using this code:
<?php
$serverName = "MyPCName\\sqlexpress, 49172"; //(default port is 1433)
$connectionInfo = array( "Database"=>"News4CodeIgniter", "UID"=>"sa", "PWD"=>"MyPassword");
$conn = sqlsrv_connect( $serverName, $connectionInfo);

if( $conn ) {
    echo "Connection established.<br />";
}else{
    echo "Connection could not be established.<br />";
    die( print_r( sqlsrv_errors(), true));


?>

So far so good, I have seen: "Connection established" on my browser.

Now I installed CI4 using Composer:
composer create-project codeigniter4/appstarter newsapp -s rc
then:
composer update
and follow all the steps from Tutorial - Static Pages with success, then News Section where I hit the problem of debugging because I obtained just an very unfriendly message: Woops! We seem to have hit a snag. Please try again later...

I had already set into app\Config\Database.php the database $default variable with:
public $default = [
'DSN'      => '',
'hostname' => 'MyPCName\\sqlexpress',
'username' => 'sa',
'password' => 'MyPassword',
'database' => 'News4CodeIgniter',
'DBDriver' => 'sqlsrv',
'DBPrefix' => '',
'pConnect' => false,
'DBDebug'  => (ENVIRONMENT !== 'production'),
'cacheOn'  => false,
'cacheDir' => '',
'charset'  => 'utf8',
'DBCollat' => 'utf8_general_ci',
'swapPre'  => '',
'encrypt'  => false,
'compress' => false,
'strictOn' => false,
'failover' => [],
'port'    => 49172,
];  


Now I'm stucked, I don't know what is happened backstage and I don't know how start debugging, where to set something and where to look for seen what is happening, why I cannot move forward.

I found into the root of my application folder the file named: env and changed the line:
#CI_ENVIRONMENT = production 
into:
CI_ENVIRONMENT = development

and restart the server with the command: 
php spark serve 
from command line . 

Starting again the application with: http://localhost:8080/news and hit again the same cryptic message:[url=http://localhost:8080/news][/url]
Woops! We seem to have hit a snag. Please try again later...

Please explain or point an tutorial for debugging for newbies, I chose CodeIgniter4 and already invest few days of work to achieve theese, now I want to move forward but I cannot without external help. Thank you in advance. 
Reply
#2

The whoops message means that there is an uncaught exception happening.
Enable development of testing mode, by changing the "environment" setting in the .env file in your project root.
The problem page should now show the exception message and stack trace, so you can see what went wrong.
Reply
#3

(09-23-2019, 08:32 PM)ciadmin Wrote: The whoops message means that there is an uncaught exception happening.
Enable development of testing mode, by changing the "environment" setting in the .env file in your project root.
The problem page should now show the exception message and stack trace, so you can see what went wrong.

Thank you for your quick answer. Now the error was revealed:
Class '\CodeIgniter\Database\sqlsrv\Connection' not found

The error is located in: SYSTEMPATH/Database\Database.php at line 84. There DBDriver parameter is set with 'sqlsrv' like I set it into: app/Config/Database.php .

Please tell me what is the name of the driver CI4 is expecting for MS SQL Server database because 'sqlsrv' is not accepted by CI4 framework.
Reply
#4

The same message is appearing now at codeigniter.com as they migrate the site to CI4. I think it's some kind of bug in the latest build.
Reply
#5

@sotiulian CI4 has mysqli, postgre, & sqlite3 drivers. The other drivers have not been ported.
Reply
#6

@bgeneto Wjere dp you see this error appearing at codeigniter.com?
Reply
#7

(09-24-2019, 05:22 AM)ciadmin Wrote: @sotiulian CI4 has mysqli, postgre, & sqlite3 drivers. The other drivers have not been ported.
Thank you again. I understand from your message that I cannot use SQL Server with CI4. Because I have to make a decision regarding of this information I need to know if you plan to have SQL Server driver integration in CI4 in the near future or you had abandon this way without a time horizon.
Reply
#8

We plan to have a "drive" to port the other CI3 drivers to CI4, and to add PDO to the mix.
When that will happen is up to the community, and their willingness to kick in.
If you, for instance, wanted to port the CI3 mssql driver, that would be favorably regarded Smile
Reply
#9

How can I do that ? What does this suppose ?
Reply
#10

In the .env file -> "DATABASE" -> "DBDriver", change "sqlsrv" to "SQLSRV"
This is how I fix "Class '\CodeIgniter\Database\sqlsrv\Connection' not found" issues
Reply




Theme © iAndrew 2016 - Forum software by © MyBB